Primitives: Difference between revisions

From The K Language Wiki
Content added Content deleted
(fixpoint, for, while)
(link named primitives)
Line 105: Line 105:
|-
|-
|utility
|utility
| [[Sin(oK)|in]] prm
| [[in]] [[prm]]
|in within bin like find freq prm cmb
| [[in]] [[within]] [[bin]] [[like]] [[find]] [[freq]] [[prm]] [[cmb]]
|
|
|-
|-
|math
|math
|sin [[cos]] exp log
| [[sin]] [[cos]] [[exp]] [[log]]
|sqrt sin cos abs [n]log [n]exp [n]rand
| [[sqrt]] [[sin]] [[cos]] [[abs]] [n][[log]] [n][[exp]] [n][[rand]]
|
|
|-
|-
|stats
|stats
|
|
|count first last min max sum avg var dev med
|[[count]] [[first]] [[last]] [[min]] [[max]] [[sum]] [[avg]] [[var]] [[dev]] [[med]]
|
|
|-
|-
|table(K7+)
|table(K7+)
|
|
|[[asc]] [[dsc]] [[key]]
|<nowiki>[f]asc [f]dsc [f]key [select|update]A by B from T where C</nowiki>
|
|
|-
|-
|misc
|misc
|
|
|min max asc
|[[min]] [[max]] [[asc]]
|
|
|}
|}

Revision as of 16:03, 30 July 2021

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. Symbol primitives can be either 1 or 2 characters long.

Verbs

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

Empty cells indicate that the primitives are the same as K4-K6.

Table of Primitives in major dialects
K3 K4-K6 K9
monad dyad monad dyad monad dyad
: identity right
+ transpose add
- negate subtract
* first multiply
% reciprocal 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
^ shape power null? except, fill sort cut
# length take, reshape filter
_ floor, lowercase drop, delete, cut filter-out
$ string pad, cast
? distinct, random-float find, random
@ atom? type at cast
. eval, values dot
Table of named primitives based on implementation
oK K7 K9
utility in prm in within bin like find freq prm cmb
math sin cos exp log sqrt sin cos abs [n]log [n]exp [n]rand
stats count first last min max sum avg var dev med
table(K7+) asc dsc key
misc min max asc

Adverbs

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