KG(1)
π kg(1) β bestie edition π
okay so listen up, bestie, because I'm about to put you ON to something iconic. we're talking about kg, aka Klong, and honestly? it's giving main character energy in the array-programming world. π₯
β¨ NAME β¨
kg β literally just Klong, no cap π
πΈ SYNOPSIS πΈ
kg [-dhnqsu] [-e expr] [-l file] [-o file] [-r expr] [-t file]
[file [args]]
π¦ DESCRIPTION π¦
So Klong is this programming language that rolls with the Array programming paradigm β think terse, think sleek, think syntax that literally resembles K. It's that girl. π
It comes with a REPL (yes, a whole interactive vibe), plus a basic set of libraries: math, statistics, csv, and other utils. Little starter pack, but make it slay. β¨
The kg utility gives you all these options, and every single one matters, so don't skip:
π OPTIONS π
-dβ debug mode, bestie. it prints bytecode and call traces so you can see exactly what's going down. π-e exprβ evaluate an expression and dip β no interactive mode, we're being efficient.-hβ display usage info and exit immediately. the "help me understand" button, periodt.-l fileβ load a program from a file. bring your own code to the party. π-nβ clean start: don't parseKLONGOPTS, don't load any image. must be the first option! like, no exceptions, it's the opening act. π-o fileβ output image to a file, then exit. save your work and bounce. β¨-qβ quiet mode: no banner, no prompt, and it exits on errors. lowkey minimalist vibes. π€«-r exprβ run an expression (like-e, but it doesn't print the result). stealth mode activated. π₯·-sβ skip the first line (#!) in script files. she doesn't need the shebang, she's already that girl. πββοΈ-t fileβ send the transcript to a file. receipts, but make it text. πfile [args]β run a program with arguments, then exit. go off, king. π-- argsβ bind the remaining arguments to.a. the rest of the squad gets assigned. π«Ά
π ENVIRONMENT π
KLONGPATH β Klong looks for modules (peep the Reference below) in all directories specified by the KLONGPATH environment variable. directory names in KLONGPATH are separated by colons. when KLONGPATH is undefined, it defaults to ".:lib". so that's the default, no cap. ποΈ
π CONDITIONALS π
these are the if-then-else situations, and they're literally so useful:
:[a;b;c] = if a then b else c
:[a;b:|c;d;e] = :[a;b;:[c;d;e]]
:[a;b:|c;d:|e;f;g] = :[a;b;:[c;d;:[e;f;g]]
:[0;:yes;:no] --> :no
:[[];:yes;:no] --> :no
:["";:yes;:no] --> :no
:[x;:yes;:no] --> :yes :" for all other x"
like, if a is 0, empty list [], or empty string "", you get :no. everything else? :yes. iconic. β
π§ ADVERBS π§
okay these are the little modifiers that change how functions behave, and they are highkey essential:
- Each β
f'aβf(a1),...,f(aN) - Each2 β
a f'bβf(a1;b1),...,f(aN;bN) - Each-Left β
a f:\bβf(a;b1),...,f(a;bN) - Each-Right β
a f:/bβf(b1;a),...,f(bN;a) - Each-Pair β
f:'bβf(a1;a2),...,f(aN-1;aN) - Over β
f/aβf(...f(f(a1;a2);a3)...;aN) - Over-Neutral β
a f/bβf(...f(f(a;b1);b2)...;bN) - Converge β
f:~aβwhile ~a=f(a) do a::f(a); return a - While β
a f:~bβwhile a(b) do b::f(b); return b - Iterate β
a f:*bβdo b::f(b) a times; return b - Scan-Over β
f\a - Scan-Over-Neutral β
a f\b - Scan-Converging β
f\~a - Scan-While β
a f\~a - Scan-Iterating β
a f\*a
and just so you know: the Scan-* adverbs are like their counterparts, but they collect intermediate results and return them in a list. so you get the whole journey, not just the destination. π€οΈ
β OPERATORS β
this is the whole operator table, and yes, you need all of it:
a:=b Amend a$b Format2 ~a Not
a:-b Amend-in-Depth >a Grade-Down a+b Plus
@a Atom <a Grade-Up a^b Power
:#a Char =a Group ?a Range
a:_b Cut a@b Index/Apply %a Reciprocal
a::b Define a:@b Index-in-Depth a:^b Reshape
a%b Divide a:%b Integer-Divide a!b Remainder
a_b Drop a,b Join |a Reverse
!a Enumerate a<b Less a:+b Rotate
a=b Equal ,a List ^a Shape
&a Expand/Where a~b Match #a Size
a?b Find a|b Max/Or a:#b Split
*a First a&b Min/And a#b Take
_a Floor a-b Minus a*b Times
a:$b Form a>b More +a Transpose
$a Format -a Negate :_a Undefined
that's the whole menu, bestie. learn 'em, love 'em. π
π FUNCTIONS π
β οΈ names starting with . are reserved for system use. don't touch, that's their territory.
.ac(a)β Append-Channel.oc(a)β Output-Channel.cc(a)β Close-Channel.p(a)β Print.d(a)β Display.pc()β Process-Clock.df(a)β Delete-File.r()β Read.E(a)β Evaluate.rl()β Read-Line.fc(a)β From-Channel.rn()β Random.fl()β Flush.rs(a)β Read-String.ic(a)β Input-Channel.sys(a)β System.l(a)β Load.tc(a)β To-Channel.mi(a)β More-Input.w(a)β Write.x(a)β Exit
π VARIABLES π
these are your built-in besties, always there for you:
.aβ Arguments; command line arguments.cinβ Input-Channel; standard input channel.coutβ Output-Channel; standard output channel.cerrβ Error-Channel; standard error/log channel.colsβ Columns; number of columns on the screen (80).eβ Epsilon; smallest precise real number.editβ Editor; truth value enabling line editing.fβ Function; current function.fastpowβ Fast-Power; truth value enabling fastx^yoperator.hβ Host; host operating systemitβ last result (interactive mode)
π₯ SEE ALSO π₯
- Klong Quick Reference:
https://t3x.org/klong/klong-qref.txt.html - Klong Reference:
https://t3x.org/klong/klong-ref.txt.html
π and that's the whole page, bestie. go forth and array-program like the icon you are. β¨
this gem was brought to you by Debian on 2024 09 15 β so you know it's official, fr fr. now go slay some Klong. ππ¦πΈ
π¦ where this page comes from
- nixos 26.05: klong 20221212
- nixpkgs unstable: klong 20221212
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms