Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:15
Show Gist options
  • Save rightfold/0cba0f954f11d2e9ab52 to your computer and use it in GitHub Desktop.
Save rightfold/0cba0f954f11d2e9ab52 to your computer and use it in GitHub Desktop.
(* 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