Jane Street interview question

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

Interview Answers

Anonymous

6 Apr 2012

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

3

Anonymous

3 Feb 2015

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