CPS map

1
2
3
4
5
let map f xs =
let rec map' cont = function
| [] -> cont []
| x :: xs -> map' (fun ys -> cont (f x :: ys)) xs
in map' (fun x -> x) xs