Created
October 27, 2017 00:19
-
-
Save tenderlove/9096abbd4c70610f48dacc90ae40761f 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
cons = fn (a, b) -> fn x -> x.(a, b) end end | |
car = fn (p) -> p.(fn (q, _) -> q end) end | |
cdr = fn (p) -> p.(fn (_, q) -> q end) end | |
each = fn (list, func) -> | |
iter = fn (list, func, next) -> | |
(fn (a, nil) -> func.(a) | |
(a, b) -> func.(a); next.(b, func, next) | |
end).(car.(list), cdr.(list)) | |
end | |
iter.(list, func, iter) | |
end | |
list = cons.("a", cons.("b", cons.("c", nil))) | |
each.(list, &IO.puts/1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I love it! Lisp/scheme is awesome