Created
September 23, 2012 19:19
-
-
Save linstantnoodles/3772731 to your computer and use it in GitHub Desktop.
map reduce ocaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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