type 'a mylist = 'a listcell ref
and 'a listcell = Nil | Cons of 'a * ('a mylist)
let l1 = (ref (Cons (1, ref (Cons (2,ref Nil)))))
let l2 = (ref (Cons(3, ref (Cons(4, ref Nil)))))
let rec append l1 l2 =
match l1 with
| {contents = Nil} -> (l1 := !l2; l1)
| {contents = Cons(h,t)} -> append t l2
this is what i've got so far, the goal is to append l2 to l1 i can traverse to the end of l1 and replace the ref with l2... which is what i was trying to do. but for some reason i lose everything that came before that.
any help would be appreciated, thanks