Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* revappend takes two 'a lists as arguments and concatenates them
- * with the side effect of reversing the order of the first list. *)
- let rec revappend l1 l2 =
- match l1 with
- | [] -> l2
- | h :: t -> revappend t (h::l2)
- (* reverse a list *)
- let reverse l = revappend l []
- (* Concatonate 'a list list -> 'a list should be tail recursive*)
- let concat ll =
- let rec aux ll l =
- match ll with
- | [] -> l
- | h :: t -> aux t (revappend h l)
- in reverse (aux ll [])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement