#KProgrammingLanguage

2026-01-22
How easy it is to construct an APL or K-like programming language

(by Mohammed Jamal Alrujayi)

This was an amazing article I found on the orange site published just last week. He notes that although APL and K are of the Harvard school of languages, while Lisp is of the MIT school, they are fundamentally related in their minimalism and in how the languages are structured around a single data type: Lists for Lisp, and vectors/matrices for APL. The two schools of thought were unified in the K programming language by Arthur Whitney:

On kparc.com (his personal website) he listed K’s lineage simply as “lisp and apl,” linking to Iverson’s Turing paper and Perlis’s lyrical programming.

I didn’t know much about Iverson’s family of languages (#APL, J, #BQN, K, and so on), but seeing it embedded in just a few lines of code in a high-level language like #Python suddenly makes it so much easier to understand. The syntactic keywords are basically composed of either infix operators of mapping operators, the data (constants or variables) are like leaves of the syntax tree. So all you need are three lambdas: “atom” checks if it’s argument is a number, monad serves as apply or map depending on the type of it’s arguments and abstracts it into a lambda, and “dyad” constructs an infix operator abstracted into a curried lambda. You only need those three rules!

atom = lambda x: isinstance(x, (int, float, str))
monad = lambda f: lambda x: f(x) if atom(x) else list(map(monad(f), x))
dyad = lambda f: (lambda x, y: f(x, y) if atom(x) and atom(y)
  else list(map(lambda yi: dyad(f)(x, yi), y)) if atom(x)
  else list(map(lambda xi: dyad(f)(xi, y), x)) if atom(y)
  else list(map(lambda xi, yi: dyad(f)(xi, yi), x, y)))

Now I definitely want to try this as Scheme macros!

#tech #software #Lisp #APL #KProgrammingLanguage #JProgrammingLanguage #ProgrammingLanguages #PLT

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst