Klong is an array language, like K, but without the ambiguity. If you know K or APL, you may be disappointed by Klong. If you don't know any array languages, it might explode your brain. Use at your own risk!
A Klong program is a set of functions that use various pre-defined operators to manipulate lists (vectors) and (multi-dimensional) arrays. Here is a program that checks whether a number x is prime (for x>2):
Note that Klong is a mathematical notation rather than a programming language. If you try to use it like your favorite functional/procedural/OO programming language, you will only get frustrated. Here's an explanation of the above program.
The Reference Manual (klong-ref.txt) provides a complete and detailed semi-formal description of the Klong language. It is probably the best starting point for exploring Klong.
An Introduction to Array Programming in Klong is a brand-new book (2018) that offers a detailed explanation of problem solving in Klong and array languages in general.
The Quick Reference (klong-qref.txt) summarizes the syntax and semantics of the language. It will probably only make sense if you already know K or APL.
Then there is a Really Short Introduction to Klong (klong-intro.txt), which you might want to read if you have never used an array language before.
Finally, if you already know K, here is a (probably incomplete) summary of differences between Klong and K: klong-vs-k.txt.
You can download Klong here: klong20180213.tgz (~150KB, recent changes).
Just in case, here is the previous stable version: klong20171119.tgz (~120KB).
Klong is written in pure ANSI C (C99), so it should compile on any
system providing a C compiler. Just run
make test. It also compiles natively on Plan 9!
To install Klong, just copy the
kg binary to
/usr/local/bin or some similar place and point the
KLONGPATH environment variable to the
directory of the Klong source tree.
Files ending in
.kg are Klong programs, you can load
./kg -l name (with or
without the suffix).
contact | privacy