BQN: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(β†’β€ŽImplementations: Paragraph on Singeli)
(Added the section The Name BQN)
Line 181: Line 181:
* The three 1-modifers Cells (<code>π”½Λ˜</code>), Each (<code>𝔽¨</code>), and Undo (<code>𝔽⁼</code>) are equivalent to using a right-[[operand]] of <code>Β―1</code> with the 2-modifiers Rank (<code>π”½βŽ‰Β―1</code>), Depth (<code>π”½βš‡Β―1</code>), and Repeat (<code>π”½βŸΒ―1</code>). Therefore the 2-modifiers are circled versions of the 1-modifiers (except in the case of Undo/Repeat).
* The three 1-modifers Cells (<code>π”½Λ˜</code>), Each (<code>𝔽¨</code>), and Undo (<code>𝔽⁼</code>) are equivalent to using a right-[[operand]] of <code>Β―1</code> with the 2-modifiers Rank (<code>π”½βŽ‰Β―1</code>), Depth (<code>π”½βš‡Β―1</code>), and Repeat (<code>π”½βŸΒ―1</code>). Therefore the 2-modifiers are circled versions of the 1-modifiers (except in the case of Undo/Repeat).
* Under (<code>π”½βŒΎπ”Ύ</code>) is in principle equivalent to <code>π”ΎβΌβˆ˜π”½β—‹π”Ύ</code>. Therefore, <code>⌾</code> is a combination of the glyphs <code>∘</code> and <code>β—‹</code>.
* Under (<code>π”½βŒΎπ”Ύ</code>) is in principle equivalent to <code>π”ΎβΌβˆ˜π”½β—‹π”Ύ</code>. Therefore, <code>⌾</code> is a combination of the glyphs <code>∘</code> and <code>β—‹</code>.
== The Name BQN ==
The name "BQN" was originated as a forward iteration of the letters of APL, and [https://mlochbaum.github.io/BQN/#what-kind-of-name-is-bqn "happens to match the capitals in 'Big Questions Notation'"].
[[Marshall Lochbaum]] [https://chat.stackexchange.com/transcript/message/54753804#54753804 recounts], "I obtained 'BQN' by moving each letter in 'APL' forward by one in the alphabet. I'd come up with the backronym 'Big Questions Notation' by the time I realized N doesn't come after L."Β  Marshall commented further on this in [https://www.arraycast.com/episode-7-transcript Episode 7 of the Array Cast], in response to a question starting at the 11:29 mark.


== References ==
== References ==

Revision as of 18:03, 18 May 2022


BQN is an APL-family language designed primarily by Marshall Lochbaum. Although it maintains the concept of array-driven computing and much of APL's array functionality, BQN discards all compatibility with other array languages and changes many fundamental concepts. It uses the based array model with dedicated array notation, distinguishes between data types and expression roles to give the language a context-free grammar with first-class functions, and uses a new set of glyphs with different primitive pairings. The language uses the leading axis model and tacit programming as core paradigms. Its implementation is largely self-hosted, with an array-based compiler like Co-dfns.

Implementations

BQN has several implementations,[1] with all complete ones based on self-hosted sources, which are compiled to bytecode and included as literal arrays or similar in the implementation's source. CBQN, developed by dzaima in C, is the primary implementation with the best performance. A JavaScript version can be run online. It's slower than CBQN compiled to Wasm, but easier to connect with browser functionality.

The Singeli language was developed in order to implement BQN more effectively. CBQN uses Singeli for primitive code that uses vector instructions, and can be built with or without these optimized implementations. The Singeli implementation is written in BQN and currently targets C.

dzaima/BQN

Now largely replaced by CBQN, dzaima/BQN is dzaima's independent implementation in Java, based on dzaima/APL. While dzaima/APL adds significant new functionality and is different from any other APL, dzaima/BQN follows the BQN specification closely and sometimes extends it with system functions. It has often been the first implementation to support new functionality, particularly syntax such as block headers, and was the fastest implementation before CBQN was created. It introduced the bytecode format now shared with self-hosted BQN, and was used for development and bootstrapping.

Primitives

Functions

Glyph Monadic Dyadic
+ Conjugate Add
- Negate Subtract
Γ— Sign Multiply
Γ· Reciprocal Divide
⋆ Exponential Power
√ Square Root Root
⌊ Floor Minimum
⌈ Ceiling Maximum
∧ Sort Up And
∨ Sort Down Or
Β¬ Not Span
| Absolute Value Modulus
≀ Less Than or Equal to
< Enclose Less Than
> Merge Greater Than
β‰₯ Greater Than or Equal to
= Rank Equals
β‰  Length Not Equals
≑ Depth Match
β‰’ Shape Not Match
⊣ Identity Left
⊒ Identity Right
β₯Š Deshape Reshape
∾ Join Join to
≍ Solo Couple
↑ Prefixes Take
↓ Suffixes Drop
↕ Range Windows
Β» Nudge Shift Before
Β« Nudge Back Shift After
⌽ Reverse Rotate
⍉ Transpose Reorder axes
/ Indices Replicate
⍋ Grade Up Bins Up
⍒ Grade Down Bins Down
⊏ First Cell Select
βŠ‘ First Pick
⊐ Classify Index of
βŠ’ Occurrence Count Progressive Index of
∊ Unique Mask Member of
⍷ Deduplicate Find
βŠ” Group Indices Group

Modifiers

1-modifiers in BQN use superscript symbols, while 2-modifiers use symbols with a circle, but not one with a line through it like ⌽ and ⍉.

Glyph Name(s)
Λ™ Constant
˜ Self/Swap
˘ Cells
Β¨ Each
⌜ Table
⁼ Undo
Β΄ Fold
˝ Insert
` Scan
Glyph Name(s)
∘ Atop
β—‹ Over
⊸ Before/Bind
⟜ After/Bind
⌾ Under
⊘ Valences
β—Ά Choose
βŽ‰ Rank
βš‡ Depth
⍟ Repeat

Some modifiers are closely related, and some of their glyphs are intended to allude to this:

  • The three 1-modifers Cells (π”½Λ˜), Each (𝔽¨), and Undo (𝔽⁼) are equivalent to using a right-operand of Β―1 with the 2-modifiers Rank (π”½βŽ‰Β―1), Depth (π”½βš‡Β―1), and Repeat (π”½βŸΒ―1). Therefore the 2-modifiers are circled versions of the 1-modifiers (except in the case of Undo/Repeat).
  • Under (π”½βŒΎπ”Ύ) is in principle equivalent to π”ΎβΌβˆ˜π”½β—‹π”Ύ. Therefore, ⌾ is a combination of the glyphs ∘ and β—‹.

The Name BQN

The name "BQN" was originated as a forward iteration of the letters of APL, and "happens to match the capitals in 'Big Questions Notation'".

Marshall Lochbaum recounts, "I obtained 'BQN' by moving each letter in 'APL' forward by one in the alphabet. I'd come up with the backronym 'Big Questions Notation' by the time I realized N doesn't come after L." Marshall commented further on this in Episode 7 of the Array Cast, in response to a question starting at the 11:29 mark.

References


APL dialects [edit]
Maintained APL+Win βˆ™ APL2 βˆ™ APL64 βˆ™ APL\iv βˆ™ Aplette βˆ™ April βˆ™ Co-dfns βˆ™ Dyalog APL βˆ™ Dyalog APL Vision βˆ™ dzaima/APL βˆ™ GNU APL βˆ™ Kap βˆ™ NARS2000 βˆ™ Pometo
Historical A Programming Language βˆ™ A+ (A) βˆ™ APL# βˆ™ APL2C βˆ™ APL\360 βˆ™ APL/700 βˆ™ APL\1130 βˆ™ APL\3000 βˆ™ APL.68000 βˆ™ APL*PLUS βˆ™ APL.jl βˆ™ APL.SV βˆ™ APLX βˆ™ Extended Dyalog APL βˆ™ Iverson notation βˆ™ IVSYS/7090 βˆ™ NARS βˆ™ ngn/apl βˆ™ openAPL βˆ™ Operators and Functions βˆ™ PAT βˆ™ Rowan βˆ™ SAX βˆ™ SHARP APL βˆ™ Rationalized APL βˆ™ VisualAPL (APLNext) βˆ™ VS APL βˆ™ York APL
Derivatives AHPL βˆ™ BQN βˆ™ CoSy βˆ™ ELI βˆ™ Glee βˆ™ I βˆ™ Ivy βˆ™ J βˆ™ Jelly βˆ™ K (Goal, Klong, Q) βˆ™ KamilaLisp βˆ™ Lang5 βˆ™ Lil βˆ™ Nial βˆ™ RAD βˆ™ Uiua
Overviews Comparison of APL dialects βˆ™ Timeline of array languages βˆ™ Timeline of influential array languages βˆ™ Family tree of array languages