This is a very simple prefix notation calculator implementation in JavaScript, for the purpose of demonstrating a simple lexer, parser, compiler, and interpreter for my JSConf.eu talk, "JavaScript Compilers for Fun and Profit".
They're available packaged together here:
mini-calc-golfed.js contains each component JS-golfed down to < 140 bytes.
And individually as 140byt.es forks here:
- Lexer: https://gist.github.com/1259461
- Parser: https://gist.github.com/1259487
- Interpreter: https://gist.github.com/1259489
- Compiler: https://gist.github.com/1259490
Not sure if functional
function p(a,b,c){for(a.shift(c=[]);b=a.shift();)if(b=="(")a.unshift(b),c.push(p(a));else if(b==")")return c;else c.push(b);}