*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. For a higher-level comparison, check [Why BQN?](../commentary/why.md#versus-apl-and-j). 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](arrayrepr.md#brackets) 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`.
The form `Fβ£G` (Power with a function right operand; Power limit) must be implemented with recursion instead of primitives because it performs unbounded iteration. The modifier `_while_ β {π½βπΎβπ½_π£_πΎβπ½βπΎπ©}` provides similar functionality without risk of stack overflow. It's discussed [here](control.md#low-stack-version) and called as `Fn _while_ Cond arg`.
| Functions |
| Glyph | Monadic | Dyadic |
* | β |
β | ββΌ |
! | ΓΒ΄1+β | -Λ(+Γ·β(ΓΒ΄)β’)1+βββ£ |
β | ΟβΈΓ | β’math |
~ | Β¬ | Β¬ββ/β£ |
? | β’rand.Rangeβ0 | β’rand.Deal |
β² | | Β¬ββ§ |
β± | | Β¬ββ¨ |
β΄ | β’ | β₯ |
, | β₯ | βΎβ1 |
βͺ | β₯Λ | βΎ |
β½ | β½β0βΏ1 |
β | > | β |
β | <Λ | β |
β | < | +`βΈβ |
β | <β(0<β‘) | (Β¬-Λβ’ΓΒ·+`Β»βΈ>)βΈβ |
β | {(βΎπΒ¨)β(0<β‘π©)β₯π©} | β |
β | β |
β | | {π©βΎ(π¨βΈ/)π¨β βΈβ0βπ©} |
β© | | β/β£ |
βͺ | β· | β£βΎβΛΒ¬βΈ/β’ |
β³ | β | β |
βΈ | / | β |
β | β | Give up |
β | β | Give up |
β’ | β | β’ |
β | β’BQN |
β | β’Fmt |
β₯ | | {+β(π¨βΈΓ)Β΄β½π©} |
β€ | | {>π¨|ββΓ·`βΎβ½π¨Β«Λ<π©} |
βΉ | Inverse from here | Solve |
β· | N/A | β |
| Operators |
| Syntax | Monadic | Dyadic |
βΏ | Β¨Λ | β |
β | β, or ` if associative |
Β¨ | Β¨ |
β¨ | Λ |
β£ | β |
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 |