Shakti (k9) tutorial

Next:  


k9: Manual

This manual is for Shakti (k9) build 2020.12.04.

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 similarities 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 likely 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 likely to contain errors. Unfortunately you will be less likely to be content using more bloated and slow frameworks.

Alas this manual is not as elegant as the k9 language in 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.

verb                      adverb                 noun
:   x          y          f' each                char " ab"              \l a.k
+   flip       plus    [x]f/ over (c/join)       name ``ab               \t:n x
-   minus      minus   [x]f\ scan (c\split)      int  0 2 3              \u:n x
*   first      times   [x]f':eachp               flt  0 2 3.             \v
%              divide     f/:eachr g/:over       date 2021.01.23   .z.d
&   where      min/and    f\:eachl g\:scan       time 12:34:56.789 .z.t
|   reverse    max/or     
<   asc        less       i/o  *enterprise       class                   \f
>   desc       more       0: r/w line            list (2;3.4;`c)         \fl x
=   group      equal      1: r/w char            dict [a:2;b:`c]         \fc x     
~   not        match     *2: r/w data            func {[a;b]a+b}         \fs x
!   key        key       *3: k-ipc set           expr :a+b               \cd [d]   
,   enlist     cat       *4: https get           
^   sort    [f]cut       *5: ffi/py/js/..        
#   count   [f]take                        table t:[[]i:2 3;f:2.3 4]
_   floor   [f]drop                       utable u:[[x:..]y:..]
$   string     parse      $[b;t;f] cond   ntable n:`..![[]y:..]
?   unique  [n]find                             
@   type    [n]at         @[r;i;f[;y]] amend    `js?`js d
.   value      dot        .[r;i;f[;y]] dmend    `csv?`csv t

select[G]A from T where C; update A from T where C; delete from T where C
count first last sum min max *[avg var dev med ..]; in  within bin freq rand 
exp log sin cos sqr sqrt div mod bar prm cmbmsum mavg sums deltas differ

\\ exit  /comment \trace [:return 'signal if do while]


Next: