Problem #5
March 8, 2008 – 6:00 amSimiliar solution to problem #4, I used recursion to reverse the list.
let rec reverse_list l =
match l with
| [] -> []
| (x::xs) -> (reverse_list xs) @ [x];;
myList |> reverse_list |> List.iter (printf "[%d]") ;;
The (x:xs), @ and [] symbols are necessary so that it compiles correctly.