2
19
Fork
You've already forked array
3
Implementation of Kap, an array-based programming language inspired by APL. https://kapdemo.dhsdevelopments.com/
  • Kotlin 98.5%
  • Emacs Lisp 0.9%
  • CSS 0.4%
  • JavaScript 0.1%
Find a file
Elias Mårtenson a8e8419cc3
All checks were successful
ci/woodpecker/push/make Pipeline was successful
All platforms support negative zero, so there is no need to exclude any tests
2026年01月15日 16:53:18 +08:00
.idea Disable unnecessary idea warning 2025年10月07日 21:01:56 +08:00
.run Implementation of mapAppend 2024年12月23日 16:27:57 +08:00
.woodpecker Added libatomic1 to build dependencies 2025年11月08日 14:54:58 +08:00
array All platforms support negative zero, so there is no need to exclude any tests 2026年01月15日 16:53:18 +08:00
client-java Move the ODF code into its own module 2025年12月17日 22:04:17 +08:00
clientweb2 Clean up the gradle files to avoid some warnings 2025年11月24日 22:46:36 +08:00
contrib Fixed the keymap in emacs 2026年01月08日 00:42:17 +08:00
demo Updated the map api 2025年12月22日 21:49:59 +08:00
docs Cleaned up the Kap comparison document 2025年12月28日 13:40:18 +08:00
experimental Fixed a typo in the module definition file in the libreoffice connector module 2025年12月18日 00:42:29 +08:00
forms/forms-common Minor cleanup, no functional changes 2025年11月21日 22:10:40 +08:00
fxgraph First draft of graph library 2025年11月26日 20:46:08 +08:00
gradle/wrapper Update gradle to 9.2.1 2025年11月29日 19:28:39 +08:00
gui Move the ODF code into its own module 2025年12月17日 22:04:17 +08:00
gui2 Move the ODF code into its own module 2025年12月17日 22:04:17 +08:00
jline-kap Clean up the gradle files to avoid some warnings 2025年11月24日 22:46:36 +08:00
kap-util Clean up some build warnings 2025年11月08日 22:35:59 +08:00
kotlin-js-store Upgrade Kotlin to 2.3.20-Beta1 2026年01月10日 14:17:42 +08:00
mpbignum Some small fixes to the bigint code 2025年11月26日 16:25:23 +08:00
mpmaths Some small fixes to the bigint code 2025年11月26日 16:25:23 +08:00
perf-test Clean up some build warnings 2025年11月08日 22:35:59 +08:00
perf-test-jvm Upgrade to Java 25 2025年11月06日 22:17:03 +08:00
scripts The clientweb2 project should use multiple child projects 2025年11月08日 22:22:29 +08:00
standalonejs Clean up the gradle files to avoid some warnings 2025年11月24日 22:46:36 +08:00
test-tools More work on formatter 2025年07月27日 01:49:45 +08:00
text-client Clean up some build warnings 2025年11月08日 22:35:59 +08:00
.gitignore Refactored some maths functions 2025年05月01日 22:21:08 +08:00
build.gradle Upgrade Kotlin to 2.3.20-Beta1 2026年01月10日 14:17:42 +08:00
COPYING Removed namespace 'graph' 2024年10月09日 21:46:42 +08:00
gradle.properties Implement rowspan and colspan in forms 2025年11月13日 23:21:58 +08:00
gradlew Update gradle wrapper to match gradle version 2025年11月10日 23:16:57 +08:00
gradlew.bat Update gradle wrapper to match gradle version 2025年11月10日 23:16:57 +08:00
README.md Update readme and build scripts to use Java 25 2025年11月08日 14:50:33 +08:00
settings.gradle Move the ODF code into its own module 2025年12月17日 22:04:17 +08:00

Kap

An implementation of an APL-like language in Kotlin. The implementation is a Kotlin Multiplatform project, and can be compiled to Java, natively and to Javascript.

Summary

Kap is an array-based language that is inspired by APL. The language provides a powerful set of tools that allows the programmer to work with arrays of data instead of element by element. This allows the code to be incredibly compact, and often reduces what would otherwise be tens or even hundreds of lines of code into single line.

Features that sets Kap apart from APL include:

  • Local variable scopes including closures
  • First class functions
  • Custom syntax extensions (this allows features like if and while to be implemented as part of the standard library rather than being part of the language syntax)
  • Lazy evaluation
  • Parallel evaluation
  • Structural under (inspired by BQN)
  • Bigint and rational arithmetic
  • Simple sound and graphic API
  • Line/bar/pie charts

The main website for the project is: https://kapdemo.dhsdevelopments.com/

What the language looks like

As a language based on APL, it uses non-ASCII symbols with most fundamental functions being a single character. This may make the language seem complicated, but it's actually rather simple once one learns the general syntax.

The first line of code in the following example assigns a string to the variable A, and the second line splits the string at instances of -, returning an array of arrays (a string in Kap is nothing more than a one-dimensional array of characters):

A ← "this-is-a-demo"
A ⊂⍨ A≠@-

Typing the above code into the REPL will display the following result:

┌→─────────────────────┐
│"this" "is" "a" "demo"│
└──────────────────────┘

The box around the result indicates that the result is an array. In this case it is a one-dimensional array with 4 elements, each of which is an array of characters (i.e. string).

More examples can be found on the Kap examples web page.

Build dependencies

The Java version of Kap has been tested on Linux, Macos and Windows. The only dependency is Java 25.

Running the JavaFX based UI

The most feature-complete way to run Kap is to use the JVM client. It provides a nicer user interface, an editor, highlighting of the location of errors, ability to draw graphics, and many other features.

To start the client, simply run:

./gradlew gui:run

Running the Linux native version

To build the native Linux version, several dependencies needs to be installed. The development packages for the following libraries needs to be available:

  • Libedit
  • Libcurl
  • ICU
  • Jansson
  • GMP
  • Ncurses
  • Alsa
  • Libffi
  • OpenSSL

Fedora Linux packages

On Fedora, the necessary packages can be installed using:

dnf install java-25-openjdk-devel jansson-devel libicu-devel libffi-devel alsa-lib-devel ncurses-devel libedit-devel gmp-devel libicu-devel libxcrypt-compat libcurl-devel openssl-devel sdl2-compat-devel

Ubuntu packages

On Ubuntu, use the following command to install the dependencies:

apt-get install openjdk-25-jdk libicu-dev libcurl4-openssl-dev libjansson-dev libgmp-dev libedit-dev libasound2-dev libffi-dev libssl-dev libsdl2-dev

Building the Linux version

To build the native Linux binary, run the following command:

./gradlew text-client:linuxMainBinaries

When running the Linux binary, the path to the standard library needs to be passed to the executable:

text-client/build/bin/linux/releaseExecutable/text-client.kexe --lib-path=array/standard-lib

There is currently no support for native compilation on Windows or OSX. As long as the dependencies are available, it should be possible to make it work. Help appreciated if anyone is interested in working on it.

Web client

The application also compiles to Javascript, and it's possible to run it in a browser. Note that some functionality is missing from the Javascript version. For example, network and file operations are currently not implemented.

You can try the web UI here: https://kapdemo.dhsdevelopments.com/clientweb2/

Documentation

Work on the documentation is in progress, but it's still limited.

There is a tutorial which is incomplete: https://kapdemo.dhsdevelopments.com/tutorial.html

The following document explains the differences between Kap and APL, which is useful for readers who already are familiar with APL: https://kapdemo.dhsdevelopments.com/kap-comparison.html

The reference documentation can be found here: https://kapdemo.dhsdevelopments.com/reference.html

Anyone interested in learning more can ask questions on the Matrix channel.

Contributions

The main repository for this project is available from Codeberg: https://codeberg.org/loke/array

For discussions about this project, feel free to join the Matrix channel: #kap:dhsdevelopments.com.