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.
Featured on the Array Cast!
- 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
- Part 8: All About Rank, and a Web Interface
- Part 9: More Tacit!
- Part 10: Wraps, Structs, a Standard Library
- Part 11: Bases and Searching
- Part 12: At Depth and Ordering
- Part 13: The Biggest Mistake, The Biggest Change
Documentation is available here and you can run the latest interpreter 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[
/⋄
/]
- trains and modifier trains [
_
]⦅
/⋄
/⦆
[_
] - multiple statements in an expression
(
/⋄
/)
- ternary expressions
⍰
/⍠
- number literals
- primitives
- nouns
-
⍬
empty vector -
∻
empty dictionary
-
- 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
-
-
√
square root -
√
root -
⌊
floor -
⌊
minimum -
⌈
ceiling -
⌈
maximum -
⸠
round -
⸠
round to nearest -
⌹
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 -
⧺
increment -
ⵧ
decrement -
ⵧ
span -
⊥
decode -
⊥
base 2 decode -
⊤
encode -
⊤
base 2 encode
-
- boolean functions
-
=
equals -
≠
not equals -
<
less -
≤
less or equal -
≥
greater or equal -
>
greater -
≡
identical -
≢
not identical -
⊲
precedes (TAO less) -
⊴
precedes or identical (TAO less or equal) -
⊵
succeeds or identical (TAO greater or equal) -
⊳
succeeds (TAO greater) -
∧
and -
∨
or -
⍲
nand -
⍱
nor -
~
not
-
- character functions
-
⌊
lowercase -
⌈
uppercase -
|
case fold -
×
case
-
- set functions
-
∪
unique -
∪
union -
∩
intersection -
~
difference -
§
symmetric difference -
≠
nub sieve - multisets?
-
- property functions
-
⍳
index of -
⍸
interval index -
∊
element of -
⍷
find -
⋷
histogram (inverse of where) -
⋷
count -
≡
depth -
⍴
shape -
≢
tally -
ϼ
rank
-
- array creation functions
-
⍳
index generator -
?
roll -
?
deal -
…
range -
…
one range -
⍮
pair -
⍮
half pair
-
- dictionary functions
-
‥
from keys and values -
߹
key-value pair -
‥
from inverted table -
߹
from pairs -
⍉
inverted table -
↓
key-value pairs -
⊃
keys -
⊇
values
-
- manipulation functions
-
↑
take -
↓
drop -
↑
mix -
↓
major cells (split is⊂⍤1
) -
⊂
enclose -
⊆
nest -
⊂
partitioned enclose -
⊆
partition -
⫇
group -
⍋
grade up -
⍒
grade down -
⍋
sort by up -
⍒
sort by down -
⊴
sort up -
⊵
sort down -
⍸
where -
∊
enlist -
⌿
replicate -
,
ravel -
⍪
join -
⍪
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
-
- lookup functions
-
⊃
first -
⊇
last -
⊇
from -
⌷
index -
⊃
pick
-
- misc functions
-
⊢
/⊣
same -
⊢
right -
⊣
left -
⍎
execute -
⍕
format -
↗
raise -
⇂
minimal (TAO minimum) -
↾
maximal (TAO maximum)
-
- operators
-
⍆
reduce (left-to-right) -
⍆
fold (seeded reduce) -
⍅
reduce back (right-to-left) -
⍅
fold back -
↟
on prefixes -
↡
on suffixes -
↡
on infixes -
↟
on outfixes -
¨
each -
ᐵ
each-left -
ᑈ
each-right -
ᑣ
boxed (⊂⍤
) -
ᑒ
on contents (⍥⊃
) -
⍣
repeat -
⍣
until -
∙
inner product -
∙
alternant? -
⊞
table -
⍤
at rank -
◡
on cells (⍤¯1
) -
◠
on scalars (⍤0
) -
⍥
at depth -
⌓
on simple scalars (⍥0
) -
@
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 -
⇾
left fork (_{(⍺ ⍶⍶ ⍵) ⍹⍹ ⍵}_
) -
⇽
right fork (_{⍺ ⍶⍶ (⍺ ⍹⍹ ⍵)}_
) -
⫤
ident (adverb returning the operand) -
⫣
lev (conjunction returning the left operand) -
⊩
dex (conjunction returning the right operand)
-
- nouns
- system names (quad names)
- support for system names in parsing and interpreting
- system nilads
-
⎕u
(constant) the uppercase alphabet -
⎕l
(constant) the lowercase alphabet -
⎕d
(constant) the digits -
⎕ts
current timestamp (year, month, day, hour, minute, second, millisecond) -
⎕unix
current Unix timestamp -
⎕io
(constant)1
-
⎕ct
(constant)1⏨¯14
-
⎕seed
(set only) seed the random number generator -
⎕math
math functions -
⎕systemInfo
system information
-
- 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? -
⎕Repr
convert an array to a representation that can be read with Execute -
⎕Assert
assertions -
⎕Delay
sleep for n seconds -
⎕Import
import a module -
⎕Type
type of a scalar
-
- system adverbs
-
⎕_BinFile
read/write binary files, with format chosen from the operand
-
- system conjunctions