Skip to content

Instantly share code, notes, and snippets.

@wavebeem
Created August 18, 2015 19:04
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 wavebeem/7205858407f7d3770ba2 to your computer and use it in GitHub Desktop.
Save wavebeem/7205858407f7d3770ba2 to your computer and use it in GitHub Desktop.
// squiggle> :set f = fn(n) match (n) { case 0 => 1 case x => x * f(x - 1) }
(function () {
'use strict';
return (false || eval)('this')['f'] = sqgl$$freeze(function (n) {
if (arguments.length !== 1) {
throw new sqgl$$Error('expected 1 argument(s), got ' + arguments.length);
}
return function ($match) {
if (sqgl$$is($match, 0)) {
return function () {
return 1;
}();
}
if (true) {
return function (x) {
return $star(x, f($minus(x, 1)));
}($match);
}
throw new sqgl$$Error('pattern match failure');
}(n);
});;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment