Skip to content

Instantly share code, notes, and snippets.

@hovsater
Created October 14, 2020 13:49
Show Gist options
  • Save hovsater/9c30c1f632d09a686575ad14dcb014fb to your computer and use it in GitHub Desktop.
Save hovsater/9c30c1f632d09a686575ad14dcb014fb to your computer and use it in GitHub Desktop.
(* Write a function append : int list -> int list -> int list such that
append l1 l2 is the concatenation of l1 and l2. *)
let rec append l1 l2 =
let rec rev acc = function
| [] -> acc
| x::xs -> rev (x::acc) xs
in
let rec aux l = function
[] -> l
| x::xs -> aux (x::l) xs
in
aux l2 (rev [] l1) ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment