morilib-apl
v0.0.0
Published
an APL Interpreter
Downloads
12
Readme
Morilib APL
Morilib APL is an APL interpreter written by JavaScript.
How to use
Write the script tag in your Web site.
<script src="kanapl.js"></script>
To create APL environment, call KANAPL function.
var aplenv = KANAPL();
APL environment has two methods.
aplenv.eval()
Evaluate the given APL program and return evaluated array or scalar.
var result = aplenv.eval("3÷2 2ρ1 2 3 4");
aplenv.put()
Bind the given array or scalar.
The array is validated and throws an error if the array is not valid.
aplenv.put("A", [1, 2, 3, 4]);
Variable name
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
APL characters
Morilib APL can use below APL features.
Morilib APL also can use ASCII sequence surrounded by #.
|Feature|APL|Morilib APL|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|←|←|#<-#|
Limitation
- 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.