Skip to content

Instantly share code, notes, and snippets.

@takuto-h
Last active October 2, 2015 16:18
Show Gist options
  • Save takuto-h/2275117 to your computer and use it in GitHub Desktop.
Save takuto-h/2275117 to your computer and use it in GitHub Desktop.
let nil = fun f -> fun g -> f
;;
let cons = fun x -> fun xs -> fun f -> fun g -> g x (xs f g)
;;
let map = fun f -> fun lst ->
lst
nil
(fun x -> fun xs -> cons (f x) xs)
;;
let sample = cons 1 (cons 2 (cons 3 nil))
;;
let show_list = fun lst ->
lst
""
(fun x -> fun s -> show x ^ s)
;;
show_list sample
;;
show_list (map (fun x -> x * 2) sample)
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment