Created
August 15, 2014 09:32
-
-
Save mathiasverraes/b557d4013718a905d8b7 to your computer and use it in GitHub Desktop.
The Little Schemer continuation example ported to Erlang
This file contains hidden or 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
-module(bla). | |
-compile(export_all). | |
a_friend(_, []) -> false; | |
a_friend(_, _) -> true. | |
main() -> | |
multiremberco(tuna, [strawberries, tuna, swordfish], fun a_friend/2). | |
multiremberco(_Atom, [], Cont) -> | |
Cont([], []); | |
multiremberco(Atom, [Atom|Tail], Cont) -> | |
multiremberco(Atom, Tail, fun(Newlat, Seen) -> Cont(Newlat, [Atom|Seen]) end); | |
multiremberco(Atom, [Head|Tail], Cont) -> | |
multiremberco(Atom, Tail, fun(Newlat, Seen) -> Cont([Head|Newlat], Seen) end). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment