npm install lambda-js
For browsers, just copy
./lib/lambda.min.js (generated by UglifyJS)and include it in a
npm test to check your changes (using nodeunit) haven't broken existing functionality. Literate programming documentation can be found inside of the
/docs directory, generated by docco.
Until ECMAScript 6 gives us the fat-arrow syntax for one-liners in functional style evaluation,
12345678910mapx => x*2reducesum val => sum + val;
Such one-liners include a lot of ugly noise:
12345678910map return x*2reduce return sum + val ;
var adder = "a,b" "return a+b";
And with that capability, and caching already-constructed lambdas so there's no performance penalty beyond the initial construction, we can have nice one-liners even before ES6:
var l = require'lambda-js';12345678910mapl"x" "x*2"reducel"sum, val" "sum + val";
Copyright (C) 2012 by David Ellis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.