_ _ ____ _ _ _ | \ | |/ ___| \ | | | | | \| | | _| \| | __| |__ | |\ | |_| | |\ | / _ _ \ |_| \_|\____|_| \_| / / | | \ \ _ ____ _ | | | | | | / \ | _ \| | \ \_| |_/ / / _ \ | |_) | | \__ __/ / ___ \| __/| |___ ____| |____ /_/ \_\_| |_____| |___________|
An APL compiler written in CoffeeScript
Runs on NodeJS or in a browser
In-browser demo (See also: Paul L Jackson's web site and repl.it)
Supports: most primitives, dfns ({⍺ ⍵}
), nested arrays, complex numbers
(1j2
), infinities (¯
or ∞
), forks and hooks, strand assignment ((a b)←c
), index
assignment (a[b]←c
), user-defined operators ({⍺⍺ ⍵⍵}
)
Doesn't support: traditional functions (∇R←X f Y
), non-zero index origin
(⎕IO
), comparison tolerance (⎕CT
), prototypes, NaN-s, modified assignment
(x+←1
), control structures (:If
), object-oriented features, namespaces
Install NodeJS.
Download apl.js and make it executable:
wget http://ngn.github.io/apl/lib/apl.js
chmod +x apl.js
Running ./apl.js
without arguments starts a REPL.
Running it with an argument executes an APL script:
./apl.js filename.apl
It can be require()
d as a CommonJS module:
var apl = require('./apl');
console.log(apl('1 2 3 + 4 5 6').toString());
or used in an HTML page:
<script src="http://ngn.github.io/apl/lib/apl.js"></script>
<script>
var result = apl('1 2 3 + 4 5 6'); // apl is a global variable
</script>