Primitives

From The K Language Wiki
Revision as of 20:55, 6 July 2021 by Ngn (talk | contribs) (→‎Adverbs)

K's primitives are designed to fit a large range of diverse functionality within the ASCII character set. This makes it typable on a keyboard, while keeping the language expressive and interesting to use.

All of K's primitives are made to be multipurpose, and have varied meanings based on the context they are used in. Primitives can be either 1 or 2 characters long.

Verbs

Single argument forms(monadic) listed first, two-argument forms(dyadic) listed second.

Table of Primitives in major dialects
K3-K6 K9
monad dyad monad dyad
: self right
+ transpose add
- negate subtract
* first multiply
% square root divide
! enum, odometer, keys mod, create dict
& where min
| reverse max
< grade up lesser
> grade down greater
= group, identity matrix equal
~ not match
, enlist concatenate
^ null? except, fill sort cut
# length take, reshape filter
_ floor, lowercase drop, delete, cut filter-out
$ string pad, cast
? distinct, random-float find, random
@ type at cast
. eval dot

Adverbs

K3-K6 K9
' each | binary search
/ fold | join | base encode
\ scan | split | base decode
': each prior | windows
/: each right
\: each left