Tutorial by Examples

To reverse a list, it isn't important what type the list elements are, only what order they're in. This is a perfect candidate for a generic function, so the same reverseal function can be used no matter what list is passed. let rev list = let rec loop acc = function | [] -...
let map f list = let rec loop acc = function | [] -> List.rev acc | head :: tail -> loop (f head :: acc) tail loop [] list The signature of this function is ('a -> 'b) -> 'a list -> 'b list, which is the most generic it can be. This does not p...

Page 1 of 1