Skip to content

Instantly share code, notes, and snippets.

@linstantnoodles
Created September 23, 2012 19:19
Show Gist options
  • Save linstantnoodles/3772731 to your computer and use it in GitHub Desktop.
Save linstantnoodles/3772731 to your computer and use it in GitHub Desktop.
map reduce ocaml
(* The map function *)
let rec map fn list =
match list with []->[]
| n::ns -> fn n::map fn ns;;
(* The reduce function *)
let rec reduce fn id list =
match list with []->id
| n::ns->fn n (reduce fn id ns);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment