TinyAPL, a tiny APL dialect and interpreter in Haskell
See the code
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!
Documentation is available here and you can run the latest interpreter here
Marked features are supported, unmarked features are planned
.¯⏨ᴊ∠∞'"
⍘
⍘⍘ -> ⍘⍘" -> "⍘n -> newline⍘r -> carriage return⍘t -> tab⍘{22be} -> unicodeabc)Abc)_Abc)_Abc_)←⋄:■{...}, dadvs _{...}, dconjs _{...}_⍺ left argument, ⍵ right argument, ⍺⍺ left array operand, ⍶⍶ left function operand, ⍵⍵ right array operand, ⍹⍹ right function operand∇ recurse function, _∇ recurse adverb, _∇_ recurse conjunction⍝
⟃/⟄⎕ and ⍞⟨/⋄/⟩ and [/⋄/]_]⦅/⋄/⦆[_](/⋄/)⍰/⍠⍬ empty vector∻ empty dictionary⦻ null∅ nan+ conjugate+ add- negate- subtract× direction× multiply÷ reciprocal÷ divide
0÷0 is 1x÷0 is an error* exponential* power⍟ ln⍟ log
1⍟1 is 11⍟y is an errorx⍟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= 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⌊ lowercase⌈ uppercase| case fold× case∪ unique∪ union∩ intersection~ difference§ symmetric difference≠ nub sieve⍳ index of⍸ interval index∊ element of⍷ find⋷ mask⋵ histogram (inverse of where)⋵ count≡ depth⍴ shape≢ tallyϼ rank⍳ index generator? roll? deal… range… one range⍮ pair⍮ singleton‥ from keys and values߹ key-value pair‥ from inverted table߹ from pairs⍉ inverted table↓ key-value pairs⊃ keys⊇ values↑ 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⊃ first⊇ last> first cell≥ last cell⊇ from⌷ index⊃ pick⊢/⊣ same⊢ right⊣ left⍎ execute⍕ format↗ raise⇂ minimal (TAO minimum)↾ maximal (TAO maximum)/ 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⍨ 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)⎕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⎕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⎕_BinFile read/write binary files, with format chosen from the operandHaskell
90.1%
TypeScript
7.7%
HTML
1.8%
TinyAPL, a tiny APL dialect and interpreter in Haskell
See the code
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!
Documentation is available here and you can run the latest interpreter here
Marked features are supported, unmarked features are planned
.¯⏨ᴊ∠∞'"
⍘
⍘⍘ -> ⍘⍘" -> "⍘n -> newline⍘r -> carriage return⍘t -> tab⍘{22be} -> unicodeabc)Abc)_Abc)_Abc_)←⋄:■{...}, dadvs _{...}, dconjs _{...}_⍺ left argument, ⍵ right argument, ⍺⍺ left array operand, ⍶⍶ left function operand, ⍵⍵ right array operand, ⍹⍹ right function operand∇ recurse function, _∇ recurse adverb, _∇_ recurse conjunction⍝
⟃/⟄⎕ and ⍞⟨/⋄/⟩ and [/⋄/]_]⦅/⋄/⦆[_](/⋄/)⍰/⍠⍬ empty vector∻ empty dictionary⦻ null∅ nan+ conjugate+ add- negate- subtract× direction× multiply÷ reciprocal÷ divide
0÷0 is 1x÷0 is an error* exponential* power⍟ ln⍟ log
1⍟1 is 11⍟y is an errorx⍟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= 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⌊ lowercase⌈ uppercase| case fold× case∪ unique∪ union∩ intersection~ difference§ symmetric difference≠ nub sieve⍳ index of⍸ interval index∊ element of⍷ find⋷ mask⋵ histogram (inverse of where)⋵ count≡ depth⍴ shape≢ tallyϼ rank⍳ index generator? roll? deal… range… one range⍮ pair⍮ singleton‥ from keys and values߹ key-value pair‥ from inverted table߹ from pairs⍉ inverted table↓ key-value pairs⊃ keys⊇ values↑ 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⊃ first⊇ last> first cell≥ last cell⊇ from⌷ index⊃ pick⊢/⊣ same⊢ right⊣ left⍎ execute⍕ format↗ raise⇂ minimal (TAO minimum)↾ maximal (TAO maximum)/ 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⍨ 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)⎕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⎕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⎕_BinFile read/write binary files, with format chosen from the operandHaskell
90.1%
TypeScript
7.7%
HTML
1.8%