Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
@ijunaid8989

This comment has been minimized.

Copy link

@ijunaid8989 ijunaid8989 commented Oct 27, 2017

You wrote all this to print

iex(8)> each.(list, &IO.puts/1)
a
b
c
:ok

this?

@tenderlove

This comment has been minimized.

Copy link
Owner Author

@tenderlove tenderlove commented Oct 27, 2017

Yes

@kevinjonesevans

This comment has been minimized.

Copy link

@kevinjonesevans 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
You can’t perform that action at this time.