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
- Part 14: (Wrap Your Head Around) Dictionaries
- Part 15: Extra Arguments
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 -
⦻null -
∅nan
-
- number functions
-
+conjugate -
+add -
-negate -
-subtract -
×direction -
×multiply -
÷reciprocal -
÷divide-
0÷0is1 -
x÷0is an error
-
-
*exponential -
*power -
⍟ln -
⍟log-
1⍟1is1 -
1⍟yis an error -
x⍟0is 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⊕yis$x + iy$ ) -
⊕pure imaginary (⊕yis$iy$ ) -
⊗polar (x⊗yis$xe^{iy}$ ) -
⊗unit polar (⊗yis$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 -
⋷mask -
⋵histogram (inverse of where) -
⋵count -
≡depth -
⍴shape -
≢tally -
ϼrank
-
- array creation functions
-
⍳index generator -
?roll -
?deal -
…range -
…one range -
⍮pair -
⍮singleton
-
- 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 -
>first cell -
≥last cell -
⊇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) -
ᓗcells-left (⍤¯1‿∞) -
ᓚcells-right (⍤∞‿¯1) -
⍥at depth -
⌓on simple scalars (⍥0) -
@at -
⌸key -
⌸key with vocabulary -
⍁diagonals? -
⌺stencil -
⁖valences (call left if monad and right if dyad) -
⍢strucutral under -
∵bitwise -
⎊catch
-
- 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 -
⎕tscurrent timestamp (year, month, day, hour, minute, second, millisecond) -
⎕unixcurrent Unix timestamp -
⎕io(constant)1 -
⎕ct(constant)1⏨¯14 -
⎕seed(set only) seed the random number generator -
⎕mathmath functions -
⎕systemInfosystem information
-
- 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 -
⎕Existsdoes a variable exist? -
⎕Reprconvert an array to a representation that can be read with Execute -
⎕Assertassertions -
⎕Delaysleep for n seconds -
⎕Importimport a module -
⎕Typetype of a scalar
-
- system adverbs
-
⎕_BinFileread/write binary files, with format chosen from the operand
-
- system conjunctions
