Created
May 4, 2014 23:18
-
-
Save AeroNotix/fbe36133e858349418f8 to your computer and use it in GitHub Desktop.
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
module type S = sig | |
type 'a t | |
val fold : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc | |
end | |
module MyFolder = struct | |
type 'a t = (int * 'a) list | |
let fold (a : 'a t) ~init ~f = | |
let rec aux prev = function | |
| [] -> prev | |
| hd :: tl -> aux (f prev hd) tl in | |
aux init a | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment