Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created October 27, 2017 00:19
Show Gist options
  • Save tenderlove/9096abbd4c70610f48dacc90ae40761f to your computer and use it in GitHub Desktop.
Save tenderlove/9096abbd4c70610f48dacc90ae40761f to your computer and use it in GitHub Desktop.
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)
@kevinjonesevans
Copy link

kevinjonesevans commented Oct 29, 2017

I love it! Lisp/scheme is awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment