Define the combine functions that alternate the elements of two lists
lazy and eager. The results should be saved in a lazy / eagery form.
My eager code:
match a with
| [] -> b
| x :: a' -> x :: combine b a';;
combine [-6;-5;-4] [1;2;3];;
combine [] [1;2;3];;
combine [1;2;3] [];;
combine [5;4;3;2] [1;2;3;4;5;6];;
Now lazy:
I know there is something like this to make lists Lazy:
type 'a llist = LNil | LCons of 'a * (unit -> 'a llist);;
let rec toLazyList = function
[] -> LNil
| h::t -> LCons(h, function () -> toLazyList t);;
But how actually change the body of function? I’ve looked into different examples, but have no idea how to change my code…