-
-
Save rightfold/0cba0f954f11d2e9ab52 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
(* this *) | |
sub map(xs, f, go result = list()) { | |
if empty?(xs) { | |
result; | |
} else { | |
go(tail(result), f, f(head(xs)) :: result); | |
} | |
} | |
(* is transformed into this *) | |
sub map(xs, f) { | |
sub __go(xs, f, result) { | |
if empty?(xs) { | |
result; | |
} else { | |
__go(tail(result), f, f(head(xs)) :: result); | |
} | |
} | |
__go(xs, f, list()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment