*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/doc/fromDyalog.html).* # BQN–Dyalog APL dictionary A few tables to help users of Dyalog APL (or similar) get started quickly on BQN. Here we assume `βŽ•ML` is 1 for Dyalog. ## Terminology ### Array model BQN uses the [based array model](based.md), so that a Dyalog simple scalar corresponds to many BQN values: an atom, its enclose, and so on. | Dyalog | BQN | |---------------|-------| | Simple scalar | Atom | | Scalar | Unit | | Vector | List | | Matrix | Table | BQN shares the terms "cell" and "major cell" with Dyalog, and uses "element" (which may mean different things to different Dyalog users) *not* for a 0-cell but for the value it contains. ### Roles Dyalog uses value types (array, function, and so on) to determine syntax while BQN uses a separate concept called syntactic roles. See [context-free grammar](context.md). | Dyalog type | BQN role | |------------------|------------| | Array | Subject | | Function | Function | | Monadic operator | 1-modifier | | Dyadic operator | 2-modifier | | Niladic function | *go away* | ## Syntax BQN comments are written with `#`, not `⍝`. BQN strings use double quotes `""` while single quotes `''` enclose a character. BQN's functions use `{}`, like Dyalog's dfns. The names for inputs and self-reference are different: | Dyalog | BQN | |--------|-----| | `⍺` | `𝕨` | | `⍡` | `𝕩` | | `βˆ‡` | `π•Š` | | `⍺⍺` | `𝔽` | | `⍡⍡` | `𝔾` | | `βˆ‡βˆ‡` | `𝕣` | BQN doesn't have guards: it uses modifiers or [control structures](control.md) instead. However, BQN function and modifier blocks have headers that allow pattern matching. See the [block](block.md) documentation. The assignment arrow `←` defines a new variable in a block, while `↩` modifies an existing one. BQN uses the ligature character `β€Ώ` for stranding, instead of plain juxtaposition. It also has a [list notation](syntax.md#list-notation) using `⟨⟩`. ## For reading Here are some closest equivalents in Dyalog APL for the BQN functions that don't use the same glyphs as APL. Correspondence can be approximate, and `⌽` is just used as a decorator to mean "reverse some things". | BQN | `⋆` | `√` | `∧` | `∨` | `Β¬` | `=` | `β‰ ` | `<` | `>` | `β‰’` | `β₯Š` | |:-----:|:---:|:--------:|:-----:|:-----:|:-----:|:-----:|:---:|:---:|:---:|:---:|:---:| | Monad | `*` | `*∘(Γ·2)` | `[⍋]` | `[⍒]` | `~` | `≒⍀⍴` | `β‰’` | `βŠ‚` | `↑` | `⍴` | `,` | | Dyad | `*` | `*∘÷⍨` | `∧` | `∨` | `1+-` | `=` | `β‰ ` | `<` | `>` | `β‰’` | `⍴` | | BQN | `∾` | `≍` | `↑` | `↓` | `↕` | `Β»` | `Β«` | |:-----:|:-----:|:------:|:----:|:-------:|:----:|:------------:|:-------------:| | Monad | `βŠƒ,⌿` | `↑,β₯βŠ‚` | `,⍀` | `⌽,βŒ½β€βŒ½` | `⍳` | `≒↑(Β―1-β‰’)β†‘βŠ’` | `-⍀≒↑(1+β‰’)β†‘βŠ’` | | Dyad | `βͺ` | `↑,β₯βŠ‚` | `↑` | `↓` | `,⌿` | `β‰’β€βŠ’β†‘βͺ` | `-β€β‰’β€βŠ’β†‘βͺ⍨` | | BQN | `/` | `⍋` | `⍒` | `⊏` | `βŠ‘` | `⊐` | `βŠ’` | `∊` | `⍷` | `βŠ”` | |:-----:|:---:|:---:|:-----:|:----:|:---:|:-----:|:---:|:---:|:---:|:----------:| | Monad | `⍸` | `⍋` | `⍒` | `⊣⌿` | `βŠƒ` | `βˆͺ⍳⊒` | `…` | `β‰ ` | `βˆͺ` | `⌸` | | Dyad | `⌿` | `⍸` | `⌽⍸⌽` | `⌷` | `βŠƒ` | `⍳` | `…` | `∊` | `⍷` | `⌸` or `βŠ†` | Modifiers are a little harder. Many have equivalents in some cases, but Dyalog sometimes chooses different functionality based on whether the operand is an array. In BQN an array is always treated as a constant function. | BQN | `Β¨` | `⌜` | `˝` | `βŽ‰` | `⍟` | `˜` | `∘` | `β—‹` | `⟜` | |:------:|:---:|:----:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| | Dyalog | `Β¨` | `∘.` | `⌿` | `⍀` | `⍣` | `⍨` | `⍀` | `β₯` | `∘` | In BQN `βŽ‰` is Rank and `∘` is Atop. Dyalog's Atop (`⍀`) and Over (`β₯`) were added in version 18.0. ## For writing The tables below give approximate implementations of Dyalog primitives for the ones that aren't the same. First- and last-axis pairs are also mostly omitted. BQN just has the first-axis form, and you can get the last-axis form with `βŽ‰1`.
Functions
Glyph Monadic Dyadic
* ⋆
⍟ ⋆⁼
! Γ—Β΄1+↕ -˜(+Γ·β—‹(Γ—Β΄)⊒)1+β†•βˆ˜βŠ£
β—‹ Ο€βŠΈΓ— β€’math
~ ¬ ¬∘∊/⊣
? Library?
⍲ ¬∘∧
⍱ ¬∘∨
⍴ β‰’ β₯Š
, β₯Š βˆΎβŽ‰1
βͺ β₯ŠΛ˜ ∾
↑ > ↑
↓ <˘ ↑
βŠ‚ < +`βŠΈβŠ”
βŠ† <⍟(0<≑) βŠ”
∊ {0=≑𝕩:β₯Šπ•©β‹„βˆΎβ₯Šπ•ŠΒ¨π•©} ∊
βŠƒ βŠ‘
⍀ /⁼
∩ ∊/⊣
βˆͺ ⍷ ⊣∾∊˜¬⊸/⊒
⍳ ↕ ⊐
⍸ / ⍋
⍋ ⍋ Give up
⍒ ⍒ Give up
β‰’ β‰  β‰’
⍎ β€’Eval
⍕ β€’Fmt
βŠ₯ {+⟜(π•¨βŠΈΓ—)Β΄βŒ½π•©}
⊀ {𝕨|1β†“βŒŠβˆ˜Γ·`βŒΎβŒ½π•¨βˆΎ<𝕩}
⌹ +Λβˆ˜Γ—βŽ‰1β€ΏβˆžβΌ I guess
⌷ N/A ⊏
Operators
Syntax Monadic Dyadic
⌿ ¨˝ ↕
⍀ ↑ or `
Β¨ Β¨
⍨ ˜
⍣ ⍟
f.g f˝∘gβŽ‰1β€Ώβˆž
∘.f f⌜
A∘g A⊸g
f∘B f⟜B
f∘g f⟜g
f⍀B fβŽ‰B
f⍀g f∘g
fβ₯g fβ—‹g
f@v f⌾(v⊸⊏)
f⍠B Uh
f⌸ βŠβŠ”β†•βˆ˜β‰ βŠβŠΈβŠ”
f⌺B ↕
A⌢ β€’Something
f& Nothing yet