Last active
December 15, 2015 19:09
-
-
Save aliou/5309178 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(* val map_reduce : int list -> int list list = <fun> *) | |
let map_reduce lst = | |
let rec partition acc = function | |
| 0 -> acc | |
| x -> partition ((x mod 10) :: acc) (x / 10) | |
in let rec map acc = function | |
| [] -> List.rev acc | |
| h :: tl -> | |
if h > 10 then map ((partition [] h) :: acc) tl | |
else map ((h :: [] ) :: acc) tl | |
in map [] lst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment