tinyapl
tinyapl copied to clipboard
TinyAPL, a tiny APL dialect and interpreter in Haskell
TinyAPL

TinyAPL (read like tiny apple) is a tiny APL dialect and interpreter in Haskell. It is being implemented as a series of articles available here.
- Part 1: Introduction & Arrays
- Part 2: Functions & Operators
- Part 3: More Primitives
- Part 4: Finally, Parsing!
- Part 5: Array Notation and Reductions
- Part 6: Tests, Docs, Each
- Part 7: Quads, Key, Index
Documentation is available here
Features
Marked features are supported, unmarked features are planned
- Types
- [x] Arrays
- [x] complex numbers
- [x] unicode characters
- [x] boxes (nested arrays)
- [x] Functions
- [x] Monadic Operators ("Adverbs")
- [x] Dyadic Operators ("Conjunctions")
- [x] Arrays
- Syntax
- [x] number literals
- [x] decimal point
. - [x] negative sign
¯ - [x] exponent notation
⏨ - [x] complex notation
ᴊ - [ ] complex phase notation?
∠ - [ ] infinities
∞
- [x] decimal point
- [x] character literals
' - [x] string literals
"- [x] escapes with
⍘- [x]
⍘⍘->⍘ - [x]
⍘"->" - [x]
⍘n-> newline - [x]
⍘r-> carriage return - [x]
⍘t-> tab - [ ]
⍘{22be}-> unicode?
- [x]
- [x] escapes with
- [x] names
- [x] array names (
abc) - [x] function names (
Abc) - [x] monadic operator names (
_Abc) - [x] dyadic operator names (
_Abc_)
- [x] array names (
- [x] assignment
← - [x] dfns/dops
- [x] multiple statements
⋄ - [x] guards
: - [x] early return
■ - [x] dfns
{...}, dadvs_{...}, dconjs_{...}_ - [x] refer to arguments and operands:
⍺left argument,⍵right argument,⍺⍺left array operand,⍶⍶left function operand,⍵⍵right array operand,⍹⍹right function operand - [x] recursion:
∇recurse function,_∇recurse adverb,_∇_recurse conjunction
- [x] multiple statements
- [ ] comments
⍝- [x] inline comments?
⟃/⟄
- [x] inline comments?
- [x] console I/O with
⎕and⍞ - [x] array notation
⟨/⋄/⟩and[/⋄/]
- [x] number literals
- primitives
- arrays
- [x]
⍬
- [x]
- number functions
- [x]
+conjugate - [x]
+add - [x]
-negate - [x]
-subtract - [x]
×direction - [x]
×multiply - [x]
÷reciprocal - [x]
÷divide0÷0is1x÷0is an error
- [x]
*exponential - [x]
*power - [x]
⍟ln - [x]
⍟log1⍟1is11⍟yis an errorx⍟0is an error
- [x]
○pi times - [x]
○circular0○yis $\sqrt{1 - y^2}$1○yis $\sin y$¯1○yis $\arcsin y$2○yis $\cos y$¯2○yis $\arccos y$3○yis $\tan y$¯3○yis $\arctan y$4○yis $\sqrt{1 + y^2}$¯4○yis $\sqrt{y^2 - 1}$5○yis $\sinh y$¯5○yis $\mathop{\text{arsinh}} y$6○yis $\cosh y$¯6○yis $\mathop{\text{arcosh}} y$7○yis $\tanh y$¯7○yis $\mathop{\text{artanh}} y$8○yis $\sqrt{-1 - y^2}$¯8○yis $-\sqrt{-1 - y^2}$9○yis $\mathop{\text{Re}} y$¯9○yis $y$10○yis $\left|y\right|$¯10○yis $\overline y$ (conjugate of $y$)11○yis $\mathop{\text{Im}} y$¯11○yis $iy$12○yis $\mathop{\text{Arg}} y$¯12○yis $e^{iy}$
- [x]
√square root - [x]
√root - [x]
⌊floor - [x]
⌊minimum - [x]
⌈ceiling - [x]
⌈maximum - [x]
⸠round - [ ]
⸠average? - [ ]
⌹matrix inverse - [ ]
⌹matrix divide - [ ]
!factorial/gamma - [ ]
!binomial - [x]
|magnitude - [x]
|remainder - [x]
∨greatest common divisor - [x]
∧least common multiple - [x]
⊕cartesian (x⊕yis $x + iy$) - [x]
⊕pure imaginary (⊕yis $iy$) - [x]
⊗polar (x⊗yis $xe^{iy}$) - [x]
⊗unit polar (⊗yis $e^{iy}$) - [x]
∡phase - [ ]
∡atan2 - [x]
ℜreal part - [x]
ℑimaginary part - [ ]
⊥decode - [ ]
⊥base 2 decode - [ ]
⊤encode - [ ]
⊤base 2 encode
- [x]
- boolean functions
- [x]
=equals - [x]
≠not equals - [x]
<less - [x]
≤less or equal - [x]
≥greater or equal - [x]
>greater - [x]
≡match - [x]
≢not match - [x]
∧and - [x]
∨or - [x]
⍲nand - [x]
⍱nor - [x]
~not
- [x]
- set functions
- [x]
∪unique - [x]
∪union - [x]
∩intersection - [x]
~difference - [x]
§symmetric difference - [x]
≠nub sieve - [ ] multisets?
- [x]
- property functions
- [ ]
⍳index of - [ ]
⍸interval index - [ ]
∊element of - [ ]
⍷find - [ ]
⍷type? depends on if prototypes are added or not - [ ]
⋷histogram (inverse of where) - [ ]
⋷count - [ ]
≡depth - [x]
⍴shape - [x]
≢tally - [ ]
ϼrank
- [ ]
- array creation functions
- [x]
⍳index generator - [x]
?roll - [ ]
?deal - [ ]
…range? - [x]
⍮pair - [x]
⍮half pair
- [x]
- array manipulation functions
- [x]
↑take - [x]
↓drop - [ ]
↑mix - [ ]
↓major cells (split is⊂⍤1) - [x]
⊂enclose - [ ]
⊆nest - [ ]
⊂partitioned enclose - [ ]
⊆group (not partition!) - [ ]
⍋grade up - [ ]
⍒grade down - [ ]
⍋sort by up? - [ ]
⍒sort by down? - [ ]
≤sort up? useless with sort by (⍋⍨) - [ ]
≥sort down? as above - [x]
⍸where - [x]
∊enlist - [x]
⌿replicate - [ ]
⍀expand? (might not make much sense without prototypes) - [x]
,ravel - [ ]
⍪table - [ ]
⍪catenate - [x]
⍴reshape - [ ]
ϼrerank (generalized version of promote/demote: introduce leading length-1 axes or combine leading axes) - [x]
⊖reverse - [x]
⊖rotate - [ ]
⍉transpose - [ ]
⍉reorder axes - [ ]
∧promote (introduce leading axis) - [ ]
∨demote (combine two leading axes) - [ ]
,laminate
- [x]
- array lookup functions
- [x]
⊃first - [x]
⊇last - [x]
⊇from - [x]
⌷index - [ ]
⊃pick
- [x]
- misc functions
- [x]
⊢/⊣same - [x]
⊢right - [x]
⊣left - [ ]
⍎execute - [ ]
⍕format - [ ]
↗raise?
- [x]
- operators
- [x]
⍆reduce left-to-right - [ ]
⍆windowed reduce left-to-right - [x]
⍅reduce right-to-left - [ ]
⍅windowed reduce right-to-left - [x]
↟on prefixes - [x]
↡on suffixes - [x]
¨each - [x]
ᐵeach-left - [x]
ᑈeach-right - [ ]
⍣repeat (with inverses?) - [ ]
⍣until - [ ]
∙inner product - [ ]
∙alternant? - [ ]
⊞outer product - [ ]
⍤at rank - [ ]
⍥at depth - [ ]
@at - [x]
⌸key - [ ]
⌸key with vocabulary - [ ]
⍁diagonals? - [ ]
⌺stencil - [ ]
⁖valences (call left if monad and right if dyad) - [ ]
⍢strucutral under
- [x]
- combinators
- [x]
⍨constant - [x]
⍨commute - [x]
⍨duplicate - [x]
∘bind argument - [x]
∘after - [x]
⍛default argument (uses operand if called monadically, and argument if called dyadically) - [x]
⍛before (not a hook!) - [x]
⊸left hook - [x]
⟜right hook - [x]
⍤atop - [x]
⍥over - [ ]
⸚mirror (_{(⍵ ⍹⍹ ⍺)⍶⍶(⍺ ⍹⍹ ⍵)}_) - [ ]
«/»fork?
- [x]
- arrays
- system names (quad names)
- [x] support for system names in parsing and interpreting
- system arrays (nilads, i guess)
- [x]
⎕u(constant) the uppercase alphabet - [x]
⎕l(constant) the lowercase alphabet - [x]
⎕d(constant) the digits - [ ]
⎕tscurrent Unix timestamp - [x]
⎕io(constant)1 - [x]
⎕ct(constant)1⏨¯14 - [x]
⎕seed(set only) seed the random number generator
- [x]
- system functions
- [ ]
⎕Fileread/write files - [ ]
⎕DateTime(or⎕DTmaybe?) convert between time formats - [ ]
⎕HTTPhttp requests - [ ]
⎕CSVconvert from/to CSV - [ ]
⎕JSONconvert from/to JSON - [ ]
⎕Unicodeconvert between unicode representations - [x]
⎕Existsdoes a variable exist? - [ ]
⎕C/⎕Casecase fold/uppercase/lowercase - [ ]
⎕Partitionconvert Partition representation to Group representation (so that Partition is⎕Partition⍛⊆) - [x]
⎕Reprconvert an array to a representation that can be read with Execute - [ ]
⎕Assertassertions
- [ ]
- system adverbs
- [ ]
⎕_BinFileread/write binary files, with format chosen from the operand
- [ ]
- system conjunctions