Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/edfaf232a92160de7647 to your computer and use it in GitHub Desktop.
Save rightfold/edfaf232a92160de7647 to your computer and use it in GitHub Desktop.
func map(xs, f, go result = list()) {
if empty?(xs) {
result;
} else {
go(tail(xs), f, f(head(xs)) :: result);
};
}
// is sugar for
func map(xs, f) {
func __go(xs, f, result) {
if empty?(xs) {
result;
} else {
__go(tail(xs), 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