I am writing a recursive function move that takes two lists and inserts the elements from the first list to the second list in reverse order..
we have a predefined list datatype
type ilist = E | L of int * ilist
For example:
move L(2, L(3, E)) L(1, L(2, E))
would give me
L(3, L(2, L(1, L(2))))
I think i am having syntax errors with my code. Also not sure if i can prepend using cons since it is a pre-defined list datatype. Any help is appreciated!
let rec move l r =
match l with
| E -> []
| L(h,E) -> h::r
| L(h,t) -> move t r