Last active
October 2, 2015 16:18
-
-
Save takuto-h/2275117 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
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