April
The APL programming language (a subset thereof) compiling to Common Lisp.
Install / Use
/learn @phantomics/AprilREADME
April
<!-- /TITLE -->Array Programming Re-Imagined in Lisp
Ken Iverson's masterpiece reflected in the medium of Lisp.
April compiles a subset of the APL programming language into Common Lisp. Leveraging Lisp's powerful macros and numeric processing faculties, it brings APL's expressive potential to bear for Lisp developers. Replace hundreds of lines of number-crunching code with a single line of APL.
Why April?
APL veritably hums with algorithmic power. As a handful of characters run past the lexer, vast fields of data grow, morph and distil to reveal their secrets. However, APL has hitherto dwelt in an ivory tower, secluded inside monolithic runtime environments. If you have a store of data you'd like to process with APL, getting it there can be an ordeal akin to hauling tons of cargo on donkeys' backs through a narrow mountain pass. The original APL interpreters ran on mainframes whose only input was the keyboard and only output was the printer and the legacy of that implementation approach has persisted to this day, limiting the reach of the language.
But no longer. Lisp is the great connector of the software world, digesting and transforming semantic patterns in much the same way that APL works upon numeric patterns. With APL inside of Lisp, databases, streams, binary files and other media are just a few lines of code away from processing with APL.
Discussion
For the time being, discussion of April and its development is happening on the ##phantomics channel on irc.libera.chat.
Support April's Development
If you'd like to help provide for continuing work on April, you can contribute through Patreon. April is making fast and steady progress toward the goal of being a powerful, full-featured and professional APL implementation, whose ease of extension and integration with other software offers game-changing advantages in the vector language field. Did you know that April's code at the beginning of December 2021 was over 95% different from its code at the beginning of September 2020?
April Media and Publications
PLDI 2023 presentation
Presentation of paper on April's deferred evaluation features
ArrayCast interview
Developer interview exploring April's history and features
APL Seeds Presentation
Presentation of April at Dyalog's APL Seeds '22 conference
LispNYC April compiler presentation
Video outline and panel discussion showing early April design
European Lisp Symposium 2022 paper
April: APL Compiling to Common Lisp
Compatibility with Common Lisp Implementations
April puts the numeric and array processing capabilities of Common Lisp to the test. It has been verified to work with SBCL, CCL, ECL, ABCL, Clasp, Allegro CL and LispWorks. SBCL and CCL are considered fully compatible with no special provisions made in order to function. ECL and Clasp pass all tests with the help of some specific provisions addressing their differences from other CL implementations. ABCL passes all main tests with the help of some special provisions and all dfn tests except those in the tree library, which cannot be loaded due to limitations of the underlying Java virtual machine. Allegro CL and LispWorks both have a few compatibility issues causing failures of dfn tests. See this document for a list of all differences in functionality between implementations.
Automatic Installation
April is supplied by the Quicklisp library manager, so the easiest way to install April is through Quicklisp. To install April with Quicklisp, evaluate:
(ql:quickload 'april)
Manual Installation
If you'd like to install April manually from this repository, you can follow these instructions.
Cloning the Repository
First, clone the repository to a location on your system. For this example, let's say you cloned it to the directory ~/mystuff/april.
Preparing Quicklisp
Enter your Quicklisp local-projects directory (usually ~/quicklisp/local-projects) and create a symbolic link to the directory where you cloned the April repository. For example, if you cloned the repo to ~/mystuff/april and your Quicklisp directory is ~/quicklisp/, enter:
cd ~/quicklisp/local-projects
ln -s ~/mystuff/april
Installing Dependencies
To complete the installation, just start a Common Lisp REPL and enter:
(ql:quickload 'april)
This will download and install April's dependencies, and with that the package will be built and ready.
APL Functions and Operators
The APL language uses single characters to represent its primitive functions and operators. Most of these symbols are not part of the standard ASCII character set but are unique to APL. To see a list of the glyphs that are supported by April, visit the link below.
See the complete April APL lexicon here.
Some APL functions and operators won't be added to April since they don't make sense for April's design as a compiler from APL to Lisp. Others may be added in the future. See the list of features not implemented here.
Getting to Know APL
A full guide to the APL language is far beyond the scope of this file, but here are links to some good sources.
A high-level introduction to APL.
This is a detailed language tutorial covering most of the functions and operators in April.
The original paper by Ken Iverson, creator of APL, detailing the language's underlying philosophy.
If you would like a quick tour of the language, April includes a function that will print demos of all the commands and many APL syntax features. To see the demos, enter:
* (april (demo))
The * indicates a REPL prompt. Prepare for a long read. The demo content that gets printed will tell you the name(s) of the operations that correspond to each symbol and will hopefully give you some idea of what each one does.
How to Enter APL Characters
In order to write APL programs you'll need a way to use the language's special character set.
Click here for information on enabling APL input within Emacs.
Click here for information on enabling APL input within Vim.
Click here for information on enabling APL input universally within GNU/Linux.
Basic Evaluation: (april) and (april-f)
Evaluating an APL expression is as simple as:
* (april-f "1+2 3 4")
3 4 5
#(3 4 5)
As above, the * indicates a REPL prompt and the text below is the expression's output.
The macro (april-f) (short for april-format) will evaluate any APL string passed to it as the sole argument, returning the final result. Using (april-f) will also produce a printout of the output in APL's traditional array printing style, which appears before the actual output value. You can see above how the 3 4 5 is printed out before the value #(3 4 5). APL-style printed arrays are easier to read than Lisp's style of printing arrays; APL can use a simpler style to express its output because it doesn't have as many different data types and structures as Lisp.
If you don't need to see the printout, you can use the plain (april) macro. Like this:
* (april "1+2 3 4")
#(3 4 5)
You should use (april) if you're using April to do calculations inside of a larger program and don't need the printout. Otherwise, especially if you're working with large data sets, the system may consume significant resources printing out the results of calculations.
Setting state properties for the APL instance can be done like this:
* (april-f (with (:state :count-from 0)) "⍳9")
0 1 2 3 4 5 6 7 8
#(0 1 2 3 4 5 6 7 8)
Instead of an APL string, the first argument to (april) or (april-f) may be a list of parameters for the APL environment. The APL expression is then passed in the second argument.
For example, you can use the :count-from parameter to determine whether functions in the evaluated APL code will start counting from 0 or 1. We'll get into more detail on how these parameters work later.
* (april-f (with (:state :count-from 1)) "⍳9")
1 2 3 4 5 6 7 8 9
#(1 2 3 4 5 6 7 8 9)
* (april-f (with (:state :count-from 0)) "⍳9")
0 1 2 3 4 5 6 7 8
#(0 1 2 3 4 5 6 7 8)
More APL expressions:
* (april-f "⍳12")
1 2 3 4 5 6 7 8 9 10 11 12
#(1 2 3 4 5 6 7 8 9 10 11 12)
* (april-f "3 4⍴⍳12")
1 2 3 4
5 6 7 8
9 10 11 12
#2A((1 2 3 4) (5 6 7 8) (9 10 11 12))
* (april-f "+/3 4⍴⍳12")
10 26 42
#(10 26 42)
* (april-f "+⌿3 4⍴⍳12")
15 18 21 24
#(15 18 21 24)
* (april-f "+/[1]3 4⍴⍳12")
15 18 21 24
#(15 18 21 24)
* (april-f "⌽3 4⍴⍳12")
4 3 2 1
8 7 6 5
12 11 10 9
#2A((4 3 2 1) (8 7 6 5) (12 11 10 9))
* (april-f "1⌽3 4⍴⍳12")
2 3 4 1
6 7 8 5
10 11 12 9
#2A((2 3 4 1) (6 7 8 5) (10 11 12 9))
A note on escaping characters
April uses the backslash character \ to implement the expand function and the scan operator. Because of the way Lisp strings work, this character must be escaped with a second \ before it in order to enter APL code containing backslashes. For example:
* (april-f "+\\⍳5")
1 3 6 10 15
#(1 3 6 10 15)
Inside the "string", the two backslashes evaluate to a single backslash. If you forget about this, you can run into confusing errors.
Unique Language Features in April
For the most part, April's syntax and functions follow standard APL conventions. But there are a few areas where April differs from typical APL implementations along with som
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
