Skip to content

Instantly share code, notes, and snippets.

@sohang3112
Last active January 3, 2024 06:36
Show Gist options
  • Save sohang3112/c3a3f739e5f5b41a3c4f0a6ea5c94b7b to your computer and use it in GitHub Desktop.
Save sohang3112/c3a3f739e5f5b41a3c4f0a6ea5c94b7b to your computer and use it in GitHub Desktop.
BQN Notes

BQN is a modern array programming language that improves upon APL, J, etc. in various ways.

Install CBQN

CBQN is the primary implementation of BQN. It can be installed on Linux as follows:

$ git clone https://github.com/dzaima/CBQN.git
$ cd CBQN
$ make
$ sudo make install

On Windows, install in WSL, or see how to install BQN on Windows & other non-Linux platforms.

Now run bqn to start REPL, or run a BQN file with: bqn /path/to/script.bqn.

Note: In Try BQN (online), and after enabling BQN plugin for various editors (eg. Emacs, VS Code), you can type BQN characters by typing corresponding character after backtick \. Eg. \0 turns into . See the keymap for all character codes.

Online BQN REPL

BQNPAD is an online alternative REPL to CBQN. Its top bar has everything you need to know about BQN's special characters. Click to enter it, hover to see its name and the backslash combination you can type instead, and middle- or modified click to go to a help page.

Note: It is slower than CBQN, and has some limitations - for example, some system functions like •Out and •GetLine are not available.

Syntax & Functions

In VS Code BQN extension, you can hover over primitives like + and it will show its help/usage. But this currently doesn't work for system functions like •Out.

I/O

  • Output: •Out "helloworld"
  • Input: •GetLine@ - note that @ is a dummy argument passed to •GetLine.

See more system functions (system functions start with ).

Conditinals & Loops

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment