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