Comparing version 0.0.1 to 0.0.2
/* | ||
* $Id: lambda.js,v 0.1 2013/04/04 11:25:17 dankogai Exp dankogai $ | ||
* $Id: lambda.js,v 0.2 2013/04/04 16:19:55 dankogai Exp dankogai $ | ||
* | ||
@@ -31,3 +31,3 @@ * lambda.js | ||
}; | ||
var lambda = function(src, nomemo, lv) { | ||
function lambda(src, nomemo, lv) { | ||
if (!nomemo && src in lambda.memo) return lambda.memo[src]; | ||
@@ -34,0 +34,0 @@ if (!lv) lv = 0; |
@@ -1,1 +0,1 @@ | ||
(function(ctx){"use strict";var parse=function(src,lv){var body="",idx,m,i,d,l;while(m=src.match(/^([\s\S]*?)(lambda|λ)\(/)){body+=m[1];src=src.substr(m[0].length-1);for(i=d=1,l=src.length;i<l;++i){if(src.charAt(i)==="(")d++;else if(src.charAt(i)===")")d--;if(!d)break}if(i===l)throw new SyntaxError("() mismatch");var t=src.substr(1,i-1);body+=lambda(t,true,lv+1);src=src.substr(i+1)}return body+src};var lambda=function(src,nomemo,lv){if(!nomemo&&src in lambda.memo)return lambda.memo[src];if(!lv)lv=0;var parts=src.match(/^([^:]*):([\s\S]+)/),head=parts[1],body=parse(parts[2],lv);var fun=eval("(function _"+lv+"("+head+"){return "+body+"})");if(!nomemo)lambda.memo[src]=fun;return fun};lambda.memo={};ctx.λ=ctx.lambda=lambda})(this); | ||
(function(ctx){"use strict";var parse=function(src,lv){var body="",idx,m,i,d,l;while(m=src.match(/^([\s\S]*?)(lambda|λ)\(/)){body+=m[1];src=src.substr(m[0].length-1);for(i=d=1,l=src.length;i<l;++i){if(src.charAt(i)==="(")d++;else if(src.charAt(i)===")")d--;if(!d)break}if(i===l)throw new SyntaxError("() mismatch");var t=src.substr(1,i-1);body+=lambda(t,true,lv+1);src=src.substr(i+1)}return body+src};function lambda(src,nomemo,lv){if(!nomemo&&src in lambda.memo)return lambda.memo[src];if(!lv)lv=0;var parts=src.match(/^([^:]*):([\s\S]+)/),head=parts[1],body=parse(parts[2],lv);var fun=eval("(function _"+lv+"("+head+"){return "+body+"})");if(!nomemo)lambda.memo[src]=fun;return fun}lambda.memo={};ctx.λ=ctx.lambda=lambda})(this); |
{ | ||
"name": "js-lambda", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "DSL for lambda calculus", | ||
@@ -5,0 +5,0 @@ "main": "lambda.js", |
@@ -14,3 +14,3 @@ [![build status](https://secure.travis-ci.org/dankogai/js-lambda.png)](http://travis-ci.org/dankogai/js-lambda) | ||
````html | ||
<script src="lambda.js"></script> | ||
<script src="lambda.js" charset="UTF-8"></script> | ||
```` | ||
@@ -127,2 +127,2 @@ | ||
+ http://www.ruby-doc.org/core-2.0/Kernel.html#method-i-lambda | ||
+ https://developer.mozilla.org/en-US/docs/JavaScript/Reference/arrow_functions | ||
+ http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10392