Kap

From APL Wiki
Jump to navigation Jump to search


Kap is an array-based language that aims to implement most of standard APL, along with additional features. Much of standard APL works in Kap, although if an APL feature does not fit with Kap's design, those features are changed or removed.

Lazy evaluation

The main difference compared to APL is that Kap is lazy-evaluated. This means that the language gives the developers very loose guarantees when (or if, and how many times) a function will actually be invoked. For example, ↑ f¨ ⍳10 will only make a single call to f because f¨ ⍳10 will not immediately evaluate the result but only return a delayed evaluation. Since all but the first result is then discarded, those results will never be computed.

Differences from APL

The following is a list of significant differences compared to APL:[1]

  • Lazy evaluation
  • First class functions
  • Bignum support and rational arithmetic
  • Ability to define custom syntax
  • Native hash table support
  • Parallel evaluation (to take advantage of multi-core CPU's)

Primitives

Functions

Glyph Monadic Dyadic
+ Conjugate Add
- Negate Subtract
× Angle (Signum) Multiply
÷ Reciprocal Divide
| Magnitude Mod
Power
Log
= Equals
Not equals
< Increase rank Less than
> Decrease rank Greater than
Less than or equal
Greater than or equal
Sort up Logical and
Sort down Logical or
Logical nand
Logical nor
Logical not Without
Square root Root
Floor Min
Ceiling Max
! Gamma Binomial
Identity Right
Hide Left
Index lookup
Enclose Partitioned enclose
Disclose Pick
, Ravel Concatenate
Table Concatenate first axis
Take first Take
Drop first Drop
? Roll Deal
Reverse horizontally Rotate horizontally
Reverse vertically Rotate vertically
Transpose Transpose by axis
Member
Find
Grade up
Grade down
Replicate
Format
Parse number
% Case
Nest Partitioned enclose
Select
Intersection
Key ({⍺⍵}⌸ in Dyalog)
Union
Decode
Encode
Matrix inverse Matrix division
Depth Compare equal
Size of major axis Compare not equals
Return from a function

Operators

Syntax Monadic Dyadic
For each
F/ Reduce Windowed reduce
F⌿ Reduce leading axis Windowed reduce leading axis
F⌻ Outer product
F•G Inner product
F⍨ Duplicate Commute
F⍣k Power operator
F\ Scan
F⍀ Scan first axis
F⍤k Rank operator
F∵ Derive bitwise
F∥ Parallel
Inverse
F∘G Compose
F⍛G Inverse compose
F⍥G Over
F⍢G Structural under

In addition to these, Kap uses the glyphs « and » to form Forks. These are not operators, although they resemble them syntactically.

References

  1. Mårtenson, Elias. Kap for APL’ers. Unversioned. Retrieved 2023-08-13.
APL dialects [edit]
Maintained APL+WinAPL2APL64APL\ivApletteAprilCo-dfnsDyalog APLDyalog APL Visiondzaima/APLGNU APLKapNARS2000Pometo
Historical A Programming LanguageA+ (A) ∙ APL#APL\360APL/700APL\1130APL\3000APL.68000APL*PLUSAPL.jlAPL.SVAPLXExtended Dyalog APLIverson notationIVSYS/7090NARSngn/aplopenAPLOperators and FunctionsPATRowanSAXSHARP APLRationalized APLVisualAPL (APLNext) ∙ VS APLYork APL
Derivatives AHPLBQNCoSyELIGleeIIvyJJellyK (Goal, Klong, Q) ∙ KamilaLispLang5LilNialRADUiua
Overviews Comparison of APL dialectsTimeline of array languagesTimeline of influential array languagesFamily tree of array languages