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 |
|---|---|---|---|
+ Plus |
Conjugate | Add | Character offsets as BQN: 'a'+3 is 'd' |
- Minus |
Negate | Subtract | Character difference as BQN: 'd'-'a' is 3x |
× Times |
Direction | Multiply | |
÷ Divide |
Reciprocal | Divide | Exact rationals as J: 1x÷3x is 1r3 |
⌊ Floor |
Floor | Minimum | ⌊/⍬ is ∞ |
⌈ Ceiling |
Ceiling | Maximum | ⌈/⍬ is ¯∞ |
\| Stile |
Magnitude | Residue | |
* Star |
Exponential | Power | |
⍟ 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 |
⌷ Squad |
Identity | Index | |
⍳ Iota |
Index generator | Index of | |
⍸ 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 | Execute in current scope (''⍎Y) |
|
⍕ 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⌝ |
⌝ Outer |
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 |
∇ Nabla, ∇∇ Nabla nabla |
Function / operator self-reference |
: Colon, :: Error guard |
Boolean / error guard |
⋄ Diamond |
Statement or literal separator |
⍝ Comment |
Comment |
⎕← Quad |
Explicit output |
⍬ 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 |
•UCS Unicode |
Unicode code points / encodings |
•LOAD Load |
Evaluate an APL source file |
•SIGNAL Signal |
Raise an ordinary APL error |
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.