an APL Interpreter
npm install kanaplKANAPL is an APL interpreter written by JavaScript.
Write the script tag in your Web site.
``html`
To create APL environment, call KANAPL function.
`javascript`
var aplenv = KANAPL();
APL environment has two methods.
Evaluate the given APL program and return evaluated array or scalar.
`javascript`
var result = aplenv.eval("3÷2 2ρ1 2 3 4");
Bind the given array or scalar.
The array is validated and throws an error if the array is not valid.
`javascript``
aplenv.put("A", [1, 2, 3, 4]);
The characters shown as follows are vaild for variable name.
* Uppercase ASCII alphabets
* Kanji (Hanzi)
* Hiragana
* Katakana
* △
* Full width alphabets (Uppercase and Lowercase)
* Half width Katakana
KANAPL can use below APL features.
KANAPL also can use ASCII sequence surrounded by #.
|Feature|APL|KANAPL|Sequence|
|:--|:--|:--|:--|
|Negative sign| ̄| ̄|#~#|
|Addition|+|+||
|Subtraction|-|-||
|Multiplication|×|×|#*#|
|Division|÷|÷|#/#|
|Modulo/Absolute||||||
|Maximum/ceiling|⌈|「|#max#|
|Minimum/floor|⌊|」|#min|
|Power/Exponent|★|★|#**#|
|Logarithm|⍟|☆|#log#|
|Random|?|?||
|Pi/Trigonometric Function|〇|〇|#tri#|
|Factorial/Combination|!|!||
|Logical Not|~|~|#not#|
|Logical And|∧|∧|#and#|
|Logical Or|∨|∨|#or#|
|Logical Nand|⍲|†|#nand#|
|Logical Nor|⍱|‡|#nor#|
|Reduce|/|/||
|Scan/Expand|\\|\\||
|Inner product|.|.||
|Outer product|∘.|・.|#outer#|
|Shape/Reshape|ρ|ρ|#rho#|
|Concatenate|,|,||
|Take|↑|↑|#take#|
|Drop|↓|↓|#drop#|
|Reverse/Rotate|⌽|φ(Phi)|#rotate#|
|Transpose|⍉|〆|#transpose#|
|Index generator|ι|ι|#iota#|
|Member of|∈|∈ ε|#in#|
|Sort(ascending)|⍋|♯(Sharp)|#asc#|
|Sort(descending)|⍒|♭|#desc#|
|Inverse Matrix/Division Matrix|⌹|※|#domino#|
|Encode|⊥|⊥|#encode#|
|Decode|⊤|┬|#decode#|
|Execute|⍎|♪|#eval#|
|Format|⍕|◆|#tostring#|
|Assign|←|←|#<-#|
* User defined function and jump is not avaiable.
* All elements of array must be numbers or characters. (Mixed array is not available)
* All length of array in another array must be the same.