APL Language Family
1. APL apl
ID: eee94cd6-7a01-4bf1-8029-f98ba665e0b4 CREATED: <2025-02-16 Sun 20:37>
APL is the OG array PL
- inspired many other modern languages and concept models from spreadsheets to functional to DSLs.
- A Programming Language, 1962
Applied mathematics is largely concerned with the design and analysis of explicit procedures for calculating the exact or approximate values of various functions. Such explicit procedures are called algorithms or programs. Because an effective notation for the description of programs exhibits considerable syntactic structure, it is called a programming language.
- APLcart - Find your way in APL
- Talk:APL - HaskellWiki
- APL and Haskell quick comparison
https://youtube.com/watch?v=QtvvQ7MdwKY - APL keyboard layout
- TryAPL
- some great youtube tutorials and problem walkthroughs available from code_report
- Essays/Incunabulum - J Wiki
2. BQN
ID: c067cd27-99c0-4e3d-804d-e9eb1f1514ce CREATED: <2025-02-16 Sun 20:37>
- BQN: finally, an APL for your flying saucer
- Why use BQN?
- BQN tutorials
ligatures everywhere 8)
- expressions
- +-×÷⋆√˜⁼˙∘
- literals = char, num
- primitives = functions, modifiers
- 1-modifiers = superscript
- 2-modifiers = unbroken circlers
- other primitives are always functions
- to try out BQN, use the BQN online REPL it's helpful with debugging since it shows the interpreted structure via evaluation diagram
BQN's grammar is governed by syntactic roles.
Precedence Role Input roles Output role Associativity 0 () Whatever Same thing (none) 1 Modifier Function, subject Function left-to-right 2 Function Subject subject Right-to-left
- lists
- ∾≍⌽↕¨´
- companies made with 1d (K) by Arthur Whitney : Kx Systems , shakti
a string is a list of characters
"Text!"
list notation uses angle brackets, ',', newline, and '⋄' are interchangeable separators
⟨ π, ∘, "element" ⋄ ⟨'l',1,5,'t'⟩ ⟩
strands are an alternative notation for lists: '‿'
>> 2 × ⟨0‿2 ⋄ 1‿3‿5⟩ ⟨ ⟨ 0 4 ⟩ ⟨ 2 6 10 ⟩ ⟩ >> ⟨ 10, 20‿30 ⟩ + ⟨ 1‿2, 3 ⟩ ⟨ ⟨ 11 12 ⟩ ⟨ 23 33 ⟩ ⟩
- '≍' is the function for making one or two atom arguments into a list. Solo in the one-arg case, couple in the two.
'∾' is Join To (inverted lazy S), which concatenates lists
>> ⟨1,2,3⟩ ∾ "abc" ⟨ 1 2 3 'a' 'b' 'c' ⟩ >> 0 ∾ ⟨1,2,3⟩ ⟨ 0 1 2 3 ⟩ >> "plural" ∾ 's' "plurals"
'⌽' is Reverse - puts a list back to front
>> ⌽ "drawer" "reward"
with a left argument, means Rotate which shifts values over by a specified amount. positive rotates left, negative roates right.
- '¨' is the 1-modifier Each which applies the operand to every element of a list argument - it's the same as map in a functional programming language. with two list arguments (with the same length), the elements of each list are paired - like a zip function.
- '´' is Fold - reduce or accumulate functions such as `+´` which sums a list
- '↕' Range - returns all natural numbers less than subject
- natural numbers start at 0 (naturally)
- combinators
<>≠=≤≥≡≢○⊸⟜
Tacit programming does not use variables during the execution of a function (but you might use them for convenience in order to construct a tacit program). Variables allow you to use any accessible value in the program with the same level of ease. Tacit code doesn't. In fact it becomes pretty unusable when more than about three values are active at once. One consequence is that tacit code won't cause confusion by modifying far-away variables. But something unique to the tacit paradigm is that when only a small number of values are active—which is always true in a small enough portion of a program!—it has more powerful ways to describe the way these values flow through the program. The main way it achieves this is with combinators.
booleans are represented by the natural numbers 0 and 1, no built-in primitives for this. the concept and power behind this is seen in how counts and occurences work -
>> 'e' = "George Boole" ⟨ 0 1 0 0 0 1 0 0 0 0 0 1 ⟩ >> +´ 'e' = "George Boole" 3 >> 'e' +´∘= "George Boole" # With a combinator 3
- '⋆⟜-' is "Power After Negation"
- '⋆⊸-' is "Exponent Before Subtracting"
- of course have one-arg or two arg-case of Before and After, structure of application is the same.
introduced the Not function - holy crap! ¬x == 1-x gives us multiple ways to write some interesting things
>> ¬⊸× 0.5 0.25
- reintroducing fact that modifiers can be assigned to data values, also, data values can be applied as functions. specifically constant functions that just return themselves
consider the following improvement to a previous example for use of number as const function using Range
>> ↕⊸÷⟜(-⟜1) 8 ⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
or with a train, simply
(↕÷-⟜1) 8
our new base-decode function:
(@+ ·+⟜(2⊸×)´∘⌽¨ -⟜'0') "01000010"‿"01010001"‿"01001110"
- using a data value as the left operand of Before or the right operand of After is called Bind because it attaches that data value as an argument to the other operand
- variables
∧∨¬⊣⊢↑↓«»⌾
To take a proud denizen of the eternal cosmos of values, held for a fleeting instant by the course of code, and bind it. Tie it down with a name, failing always to alter its inner nature but allowing context to reform its outer appearance. So labelled, perhaps through the progress of time it will know escape, or else find itself passed through one bond to another, ever tethered. It's a task to be approached only with respect.
>> hey ← "Hi there" >> hey ∾ ", World!" "Hi there, World!"
> lol
- ← is used for declare and assign
- ↩ is just assign (after already declared)
- oh my variables have roles too
- lowercase = subject
- Uppercase = function
- _leftUnderscore = 1-modifier
- \_twoUnderscores = 2-modifier
- docs">
- how to run BQN
CBQN is the primary offline implementation - there is also a mostly usable javascript implementation. -
Probably you can figure out the easy things like calling bqn("×´1+↕6") to compute six factorial. But how do you get JS and BQN to talk to each other, for example to compute the factorial of a number n? Constructing a source string with bqn("×´1+↕"+n) isn't the best way—in fact I would recommend you never use this strategy.
Instead, return a function from BQN and call it: bqn("{×´1+↕𝕩}")(n). This strategy also has the advantage that you can store the function, so that it will only be compiled once. Define let fact = bqn("{×´1+↕𝕩}"); at the top of your program and use it as a function elsewhere.
- github/cannadayr/ebqn: A BQN virtual machine in Erlang
example of BQN characters
+-×÷⋆√⌊⌈∧∨¬|=≠≤<>≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔ `˜˘¨⁼⌜´˝˙ ∘⊸⟜○⌾⎉⚇⍟⊘◶⎊ π‿∞‿@↩←⇐→,⋄ 𝕨𝕩𝔽𝔾𝕎𝕏𝕗𝕘𝕊𝕤ℝ𝕣⦃⦄⟨⟩
See glyphs.bqn
3. K
ID: ae27740f-e1fc-4daf-bd2d-d1a4bc59d193 CREATED: <2025-02-16 Sun 20:38>
- Programming in K
- k impls
- growler/k - Codeberg.org
- kparc/ksimple: k/simple is a bare minimum k interpreter for learning purposes by arthur whitney
- http://nsl.com/k/training/idioms_K3.pdf - k2/k3 version
- Arthur Whitney's array programming language
- many dialects, the OG ones are proprietary, there are OSS alternatives.
- K (programming language)
- ngn/k is the dialect I'm using to learn
- see this repo for examples of Arthur Whitney's programming style. the side-by-side buddy allocator implementations are quite thought provoking. Arthur's version is 11 lines, the idiomatic documented C version is almost 750. b.c
In computerized society where individuality is diminished, there are those who find little or no satisfaction in strict conformity to stereotyped thinking and are searching for their own answers to life's questions and how best to live, work and find inspiration.
Although little is known about what transpired during his brief visit to the Northern Venice, the idea Arthur conceived during that trip is much better known — he had a clear and uncompromising vision of a new system.
In 1992, Whitney departed from Morgan Stanley to fully concentrate on the design of a new computer language.
- +/kei | K reference card
- https://kparc.com/
- Coding Guidelines · kevinlawler/kona
- BQN: Wild claims about K performance
- k crash course - HackMD latest update of kcc from github
- shakti homepage
- you can download the evaluation version of shakti for 30-days without charge. The enterprise version is where some of the premium features are though.
- Shakti k9 tutorials
compared to the other dialects, this is a huge amount of docs. - there is also kdb/kdb+ with the Q programming language. Also proprietary.
- As far as I know, Arthur is working more heavily on the DB side - kdb+ has web APIs, FFI (for Rust too!), IPC, ML, you name it. shakti plays well with these.