Jane Street interview question

Write an append function in OCaml. (never used OCaml before)

Interview Answers

Anonymous

Apr 6, 2012

let rec append lst el = match lst with | [] -> [el] | head :: tail -> head :: append tail el;;

3

Anonymous

Feb 3, 2015

For a tail recursive answer, let append list el = List.rev(el::List.rev(list))