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 parse KLONGOPTS, 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 fast x^y operator
  • .h β€” Host; host operating system
  • it β€” last result (interactive mode)

πŸ”₯ SEE ALSO πŸ”₯


πŸ’€ 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