Skip to content

Instantly share code, notes, and snippets.

@forestbelton
Created February 12, 2014 20:42
Show Gist options
  • Save forestbelton/8964094 to your computer and use it in GitHub Desktop.
Save forestbelton/8964094 to your computer and use it in GitHub Desktop.
curried lambdas with sweet.js
macro lam {
rule { $x:ident $y:expr -> $body:expr } => {
(function($x) { return lam $y -> $body; })
}
rule { $x:ident -> $body:expr } => {
(function($x) { return $body; })
}
}
// Macro Expands to
// lam a -> a function(a) { return a; }
// lam a b -> a + b function(a) { return function(b) { return a + b; }; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment