0.0.0 • Published 5 years ago

kanapl v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

KANAPL

KANAPL 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

KANAPL can use below APL features.
KANAPL also can use ASCII sequence surrounded by #.

FeatureAPLKANAPLSequence
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.