evaluation
kiki reads right to left. Parentheses override.
8-- 3+1 first, then *2
7
arrays
Numbers separated by spaces form an array. Brackets with ; allow expressions as elements.
1 2 3 4 5
1 2 3
5
assignment
name: expr binds a name and returns the value. Names persist for the session.
3 1 4 1 5 9
3 1 4 1 5 9
6
monadic verbs
A monadic verb takes one argument: verb arg (prefix) and is comprised of a single glyph.
0 1 2 3 4
5
5 4 3 2 1
1 1 3 4 5 9
1 2 3 4
-1 -2 -3
9
0.25
3
0 1 0 1
0 2 3
1 3 0 2 4
4 2 0 1 3
(42)
dyadic verbs
A dyadic verb takes two arguments. The : prefix marks the dyadic form: left :verb right. Dyadic verbs are always made up of two glyphs, starting with a : prefix.
7
7
12
3.5
1
0 1 2
2 3 4 5
1 1 0 0 0
0 0 0 1 1
0 0 1 0 0
1 2 3 4 5 6
3
2
1
scalar extension
Dyadic verbs broadcast automatically between a scalar and an array, or apply pair-wise between equal-length arrays.
2 4 6 8 10
9 8 7 6 5
0 0 0 1 1
5 7 9
adverbs
An adverb follows a verb glyph and produces a new monadic function. / folds (reduce), \ scans (running fold), ' maps over each element.
15
120
1
9
1 3 6 10 15
1 2 6 24 120
3 3 4 4 5 9
2 3 5
composition
Expressions compose right to left without extra punctuation.
10-- sum of 0 1 2 3 4
9 5 4 3 1 1-- sort then reverse = descending
3-- count unique values
indexing and filtering
:@ indexes by position. Pair it with & (where) and a comparison to filter.
3
3 4 5
1 1 2 3 4 5 6 9-- sort via grade up
9 6 5 4 3 2 1 1-- sort descending
5 9 6-- x:>4 gives 0 0 0 0 1 1 0 1, & gives indices 4 5 7
3-- count elements above 4
matrices
Nested bracket literals form 2D arrays. + transposes. # counts rows. * takes the first row.
1 2 3 4 5 6
1 4 2 5 3 6
2
1 2 3
named helpers
Pre-defined functions. Call like name arg.
15
120
1
9
6
1 2 3 4
3.14159
2.71828
chunk is curried — assign the partial application, then call it.
1 2 3 4 5 6
helpers with adverbs
Named helpers work with adverbs. name' maps the helper over each element of an array.
2 5-- mean of each row
6 15-- sum of each row
1 1-- min of each row
Combine with chunk to group then aggregate.
2 5 8
capstone: ten days of steps
Daily step counts (thousands) over 10 days. A full analysis using only what we have covered.
10
105
10.5
15
6
9-- range
6 7 8 9 10 11 12 13 14 15
8 20 26 41 50 61 68 82 92 105
1 3 5 7 9
5-- count: 5 out of 10 days
12 15 11 14 13
13
15 14 13