an ancient programming language adapted to a JavaScript-dominated world
JavaScript CSS APL HTML Other

readme.md

Demo

An APL interpreter written in JavaScript. Runs in a browser or on NodeJS.

Supports: most primitives, dfns ({⍺ ⍵}), nested arrays, complex numbers (1j2), infinities (¯ or ), forks and atops, strand assignment ((a b)←c), indexed 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

Used in Paul L Jackson's web site and repl.it

Offline usage

Download apl.js and run it with NodeJS to start a session:

node apl.js

Running it with an argument executes an APL script:

node apl.js filename.apl

apl.js can be require()d as a CommonJS module from JavaScript:

var apl=require('./apl')
console.log(apl('1 2 3+4 5 6').toString())

or used in an HTML page:

<script src="https://ngn.github.io/apl/apl.js"></script>
<script>
  var result=apl('1 2 3+4 5 6') //apl() is exported as a global variable
</script>

Editor support