bAsedPL (aka “Based-array APL”) is an APL-derived language that uses based arrays. It emphasizes simple, consistent notation, borrowing ideas from J and BQN.
Based arrays, named in a 1981 paper and popularized by BQN, treats numbers, characters and functions as atoms, which are collected and shaped in arrays. The atom 3 is distinct from the scalar (rank-0 array) ⊂3.
Work with whole arrays, define functions, and combine them with operators, through an interactive terminal or Python API. Numbers include approximate reals, complex numbers and exact rationals.
+/⍳10 ⍝ 55
avg←+/÷≢ ⋄ avg 2 4 9 ⍝ 5
1r3+1r6 ⍝ 1r2
bAsedPL distinguishes two application rules. Structural mapping (arithmetic, Each and indexing) preserves the mapped container, including scalars. Cell application (Rank and search) consumes complete cells, returning one result directly or assembling results over surrounding batch axes. See the language rules for the value model and examples.
Each name below links to its definitions and examples. Examples show an equivalent APL value after ⍝. A monad takes one argument; a dyad takes two. Operators take functions or arrays and derive functions. Notes give glyph-specific differences from Dyalog APL.
| Glyph | Monad | Dyad | Note |
|---|---|---|---|
+ Add |
Conjugate | Add | Character offsets as BQN: 'a'+3 is 'd' |
- Dash |
Negate | Subtract | Character difference as BQN: 'd'-'a' is 3x |
× Mul |
Direction | Multiply | |
÷ Div |
Reciprocal | Divide | Exact rationals as J: 1x÷3x is 1r3 |
⌊ Floor |
Floor | Minimum | ⌊/⍬ is ∞ |
⌈ Ceiling |
Ceiling | Maximum | ⌈/⍬ is ¯∞ |
\| Stile |
Magnitude | Residue | |
* Star |
Exponential | Exponent | |
⍟ Log |
Natural log | Logarithm | |
○ Circle |
Unit circle | Circular functions | Monad is *0j1×Y, a unit-circle point. Pi times is π |
π Pi |
Pi times | Pi fraction | Monad takes over Pi times from ○. XπY is Xπ÷Y |
√ Root |
Square root | Nth root | As BQN’s √, with complex results: √¯4 is 0j2 |
! Factorial |
Factorial | Binomial | |
ℙ Prime |
Nth prime (one-based) | Prime operations | As J’s p: with the same codes, but one-based |
⨸ Factor |
Prime factors | Exponents / factor table | As J’s q:, with ∞ and ¯∞ for J’s _ and __ |
⊛ Polynomial |
Roots / coefficients | Evaluate | As J’s p.: coefficients are constant-first |
? Question |
Roll | Deal | |
∨ Or |
Real / imaginary parts | OR / GCD | Monad as J’s +. |
∧ And |
Magnitude / angle | AND / LCM | Monad as J’s *. |
⍲ Nand |
Square | NAND | Monad as J’s *: |
⍱ Nor |
Double | NOR | Monad as J’s +: |
~ Tilde |
NOT | Without | |
= Equal |
Self-classify | Equal | Monad as J: one mask row per distinct major cell |
≠ Not equal |
Unique mask | Not equal | |
< Less |
— | Less | |
≤ Less or equal |
Decrement | Less or equal | Monad as J’s <: |
> Greater |
— | Greater | |
≥ Greater or equal |
Increment | Greater or equal | Monad as J’s >: |
≡ Match |
Depth | Match | |
≢ Tally |
Tally | Not match | |
⍴ Rho |
Shape | Reshape | ⍬⍴Y gives a rank-0 array: ⍬⍴1 2 is ⊂1 |
, Comma |
Ravel | Catenate | |
⍪ Table |
Table | Catenate first | |
⌽ Reverse |
Reverse last | Rotate last | |
⊖ Reverse first |
Reverse first | Rotate first | |
⍉ Transpose |
Transpose | Reorder / diagonal axes | |
↑ Take |
First | Take | Monad as Dyalog ⎕ML≥2, but takes a major cell: ↑2 3⍴⍳6 is 1 2 3 |
↓ Drop |
Split | Drop | |
↕ Windows |
— | Full leading-axis windows | As BQN’s ↕. Replaces windowed reduce: +/2↕1 2 3 4 is 3 5 7 |
⊂ Enclose |
Enclose | Partitioned enclose | Encloses atoms too, as BQN: (⊂3)≡3 is 0x |
⊆ Nest |
Nest | Partition | |
⊃ Mix |
Mix | Pick | Monad as Dyalog ⎕ML≥2. Pick takes cells: 2⊃2 3⍴⍳6 is 4 5 6. A string picks by key |
⌷ Squad |
Identity | Index | |
⍳ Iota |
Index generator | Index of | ⍳[axes]Y returns axis selectors |
⍸ Where |
Where | Interval index | |
∊ Member |
Enlist | Membership | |
∪ Union |
Unique | Union | |
∩ Intersection |
— | Intersection | |
⍷ Find |
— | Find | |
⍋ Grade up |
Grade up | Grade with collation | |
⍒ Grade down |
Grade down | Grade with collation | |
/ Slash |
— | Replicate last | |
⌿ Slash bar |
— | Replicate first | |
\ Backslash |
— | Expand last | |
⍀ Backslash bar |
— | Expand first | |
⊤ Encode |
Binary encode | Encode | Monad as J’s #:, but digits run along the first axis |
⊥ Decode |
Binary decode | Decode | Monad as J’s #., but digits run along the first axis |
⌹ Domino |
Matrix inverse | Matrix divide | |
⊣ Left |
Identity | Left | |
⊢ Right |
Identity | Right | |
⍎ Execute |
Execute | Keyed lookup: X⍎Y is Y⊃X |
Dyad runs no code. Dyalog executes Y in namespace X |
⍕ Format |
Format | Format by specification |
f, g are functions; a, n, r are arrays or numbers.
| Glyph | Form | Meaning | Note |
|---|---|---|---|
/ Slash |
f/ |
Reduce / seeded reduce last | Seed as BQN’s ´: 10 -/1 2 3 is ¯8. For windows use ↕ |
⌿ Slash bar |
f⌿ |
Reduce / seeded reduce first | Seed and windows as / |
\ Backslash |
f\ |
Scan / seeded scan last | Accumulates left to right as BQN’s Scan: -\1 2 3 is 1 ¯1 ¯4 |
⍀ Backslash bar |
f⍀ |
Scan / seeded scan first | Left to right as \ |
¨ Each |
f¨ |
Each | |
⍨ Commute |
f⍨, a⍨ |
Self / commute / constant | |
∘ Compose |
f∘g, a∘f, f∘a |
Compose / bind | |
⍤ Rank |
f⍤g, f⍤r |
Atop / rank | |
⍥ Over |
f⍥g |
Over | |
⍛ Behind |
f⍛g |
Behind | |
. Dot |
f.g |
Inner product | Outer product is g⌝. After an array, T.name is 'name'⊃T |
⌝ Outer product |
g⌝ |
Outer product | As BQN’s ⌜; ∘.g is a SYNTAX ERROR |
⌸ Key |
f⌸ |
Key | |
⍣ Power |
f⍣n, f⍣g, f⍣[p] |
Iterate / invert / repeat until; enclose count or predicate for history | Array counts as J’s ^:: (1∘+)⍣3 ¯2 0 3⊢10 is 13 8 10 13 |
⇄ Inverse pair |
f⇄g |
Attach an explicit inverse | As J’s :. |
⌾ Under |
f⌾g |
Transform, apply, inverse-transform | As J’s &. |
∂ Derivative |
f∂ |
Gradient / vector–Jacobian product | |
◶ Agenda |
selector◶cases |
Select and call one function | As BQN’s ◶, but one-based |
@ At |
f@a, a@g |
Functional amend | |
⌺ Stencil |
f⌺a |
Stencil |
| Form | Meaning |
|---|---|
˘ Strand |
Form a vector of values: 1˘+˘'abc' |
← Assign |
Assignment, including modified/indexed/selective forms |
→ Pipe |
Left-to-right function application |
(…) Parentheses |
Grouping / nested array literals / trains |
[…] Brackets |
Enclosure, array literals, indexing and axes |
; Semicolon |
Index-axis separator |
{…} Braces |
Defined function or operator |
⍺ Alpha, ⍵ Omega |
Left / right argument |
⍶ Alpha underbar, ⍹ Omega underbar |
Left / right operand |
∇ Del, ⍢ Del diaeresis |
Function / operator self-reference |
: Colon, :: Error guard |
Unkey / key axes; Boolean guard / error guard inside dfns |
⋄ Diamond |
Statement or literal separator |
⍝ Comment |
Comment |
⎕← Quad |
Explicit output |
• Bullet |
System name prefix |
⍬ Zilde |
Empty numeric vector |
'…' Quote |
Character literal |
¯ Overbar |
Negative literal sign |
∞ Infinity |
Real infinity |
Numeric notation x, r, j, E: see numbers.
Names are case-insensitive. •a and •d are constant arrays; the other names are functions, usable with operators and composition.
| Name | Meaning |
|---|---|
•a Alphabet |
Uppercase Latin alphabet |
•d Digits |
Decimal digits |
•c Case |
Unicode case conversion |
•csv CSV |
CSV text ↔ keyed column vectors |
•r Regex |
Compiled search, captures and replacement |
•normal, •binomial, … Distributions |
Sampling, density, CDF and quantiles; 17 families |
•json JSON |
JSON text ↔ arrays and keyed vectors |
•vfi Numeric input |
Parse numeric fields with a validity mask |
•nget Read |
Read UTF-8 text or bytes |
•nput Write |
Write UTF-8 text or bytes |
•ucs Unicode |
Unicode code points / encodings |
•load Load |
Evaluate an APL source file |
•signal Signal |
Raise an ordinary APL error |
•nc Name class |
Classify visible names |
•nl Name list |
List names by class and prefix |
•src Source |
Function/operator source |
•ex Expunge |
Erase bindings |
Index origin: 1. Comparison tolerance: 1E¯14.
(⊂3)≡3 is 0x.x and r mark exact integers and rationals, as J: 1x÷3x is 1r3. Predicates, positions, tally and shape are exact.(2 3⍴⍳6)+10 20 is 2 3⍴11 12 13 24 25 26.•name, as BQN, not ⎕NAME. Most Dyalog system functions and variables are not included.K:Y evaluates its keys. T.a is 'a'⊃T, and X⍎Y is Y⊃X.