Shakti tutorial

Next:  


k9: Manual

This manual is for Shakti (k9) build 2020.10.14.

The Shakti programming language is the work of Arthur Whitney and the team at Shakti. The language comes from a lineage of similar languages going back to APL. It’s also known as k9 given the similarties to k, k2, ..., k6, k7 and the fact that Arthur also wrote those. k9 is still under development so expect a bit of syntax change and likley even more improvements.

Learning k9 means code like {x@(!#x)+\!#y} is clear and actually prefered to something much longer and verbose. You’ll have to go a bit down the rabbit hole before it starts to come together but once it does you’ll probably be happy you gave it a chance and end up learning a few things. You’ll understand how fast k9 can be in processing and analyzing data and how terse code is less likley to contain errors. Unfortunatley you will be less likley to be content using more bloated and slow frameworks.

Unfortuantely this manual is not as elegant as the k9 language such that the text version of this document is almost as big as the binary of the language.

The built-in reference screen (\) containing all the k9 commands.

universal database and language - beauty and performance.

select [count first last min max sum avg ..]A by B from T where C
delete from T where C               *update A by B from T where C
x,y      / union, insert, upsert, outerjoin, leftjoin, asofjoin ..
x+y      / equi and asof outer joins: combine markets through time
x#y x_y  / take/drop, intersect/except, inner join

Verb                      Adverb               Noun              System
:    x         y          f/  over  c/  join   bool 011b         \l a.k
+    flip      plus       f\  scan  c\  split  int  0N 0 2 3     \t:n x
-    negate    minus      f'  each  v'  has    flt  0n 0 2 3.4   \u:n x
*    first     times      f': eachp v': bin    char " ab"        \v
%              divide     f/: eachr ([n;]f)/:  name ``ab         \w
&    where     min/and    f\: eachl ([n;]f)\:  uuid              \cd x
|    reverse   max/or                         
<    asc       less                     .z.DTV date 2024.01.01T12:34:56
>    dsc       more                     .z.dtv time  12:34:56.123456789
=    group     equal      I/O                     
~    not       match      0:  r/w line         Class             \f
!    enum      key        1:  r/w char         List (2;3.4;`a)   \ft x
,    enlist    cat       *2:  r/w data         Dict `i`f!(2;3.4) \fl x
^    sort   [f]cut       *3:  kipc set         Func {[a;b]a+b}   \fc x
#    count  [f]take      *4:  http get         Expr :a+b
_    floor  [f]drop
$    string    cast+      
?    unique+   find+      $[b;x;y] if else     t:[[]i:2 3;f:3 4.;s:`a`b]
@    type   [f]at         @[x;i;f[;y]] amend   utable [[b:..]a:..]
.    value  [f]dot        .[x;i;f[;y]] dmend   xtable `..![[]a:..]
math: sqrt sqr exp log sin cos div mod bar ..  util: in bin within ..
\\   exit      / comment  #[if do while]

`csv?`csv t    / read/write csv
`json?`json t  / read/write json
python: import k;  k.k('+',2,3)   
nodejs: require('k').k('+',2,3)

*ffi: "./a.so"5:`f!"ii" /I f(I i){return 2+i;}       //cblas ..
*c/k: "./b.so"5:`f!1    /K f(K x){return ki(2+xi);}  //feeds ..
*enterprise: multi user/thread/core/machine. no limit. fast.
connect to all - depend on none

Next: