Skip to content

RubenVerg/tinyapl

Repository files navigation

TinyAPL

TinyAPL logo

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

Features

Marked features are supported, unmarked features are planned

  • Types
    • Arrays
      • complex numbers
      • unicode characters
      • boxes (nested arrays)
    • Functions
    • Monadic Operators ("Adverbs")
    • Dyadic Operators ("Conjunctions")
  • Syntax
    • number literals
      • decimal point .
      • negative sign ¯
      • exponent notation
      • complex notation
      • complex phase notation?
      • infinities
    • character literals '
    • string literals "
      • escapes with
        • ⍘⍘ ->
        • ⍘" -> "
        • ⍘n -> newline
        • ⍘r -> carriage return
        • ⍘t -> tab
        • ⍘{22be} -> unicode
    • names
      • array names (abc)
      • function names (Abc)
      • monadic operator names (_Abc)
      • dyadic operator names (_Abc_)
    • 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
    • comments
      • inline comments? /
    • console I/O with and
    • array notation // and [//]
    • trains and modifier trains [_]//[_]
    • multiple statements in an expression (//)
    • ternary expressions /
  • primitives
    • arrays
    • number functions
      • + conjugate
      • + add
      • - negate
      • - subtract
      • × direction
      • × multiply
      • ÷ reciprocal
      • ÷ divide
        • 0÷0 is 1
        • x÷0 is an error
      • * exponential
      • * power
      • ln
      • log
        • 1⍟1 is 1
        • 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
      • 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
    • 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
      • 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
      • 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
    • array 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)
  • 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 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?
      • ⎕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
      • ⎕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