[back]

Reverse Append

Implement the function

val rev_append : 'a list -> 'a list -> 'a list

so that rev_append l r is (List.rev l) @ r, but does not use the function List.rev. Your implementation must be tail recursive.

Examples

let _ = assert (rev_append [1;2;3] [4;5] = [3;2;1;4;5])
let _ = assert (rev_append [] [1;2] = [1;2])
let _ = assert (rev_append [1] [] = [1])