https://github.com/vylsaz/bqn-kernel
a jupyter kernel for BQN
https://github.com/vylsaz/bqn-kernel
bqn
Last synced: 8 months ago
JSON representation
a jupyter kernel for BQN
- Host: GitHub
- URL: https://github.com/vylsaz/bqn-kernel
- Owner: vylsaz
- License: mit
- Created: 2023-11-24T09:54:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T00:55:33.000Z (10 months ago)
- Last Synced: 2025-01-03T09:29:12.037Z (10 months ago)
- Topics: bqn
- Language: Rust
- Homepage:
- Size: 211 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bqn-kernel
a jupyter kernel for BQN
## build
Require: libcbqn on [this commit](https://github.com/dzaima/CBQN/tree/0cd1ea9bdc02652fc800d49dc672fb1119cdcbe3) or newer.
(For now:)
```
git clone https://github.com/vylsaz/bqn-kernel.git
cd bqn-kernel
```
For Windows, copy `cbqn.dll` and `cbqn.lib` to the current folder.
For Linux, make sure the dynamic linker knows where `libcbqn.so` is.
Then run:
```
cargo run
```
(add `--features v6` if you are using jupyter notebook classic)
Finally, copy the `./bqn/` folder to one of the folders listed [here](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernel-specs).
## quirks
### kernel
The kernel cannot be interrupted.
### system values
- `•Exit` doesn't work.
- `•Out`, `•Show` and `•GetLine` work.
- `•platform.environment` will report `"jupyter"`.
- `•jupyter`:
- `GetInput`: `𝕩` is prompt
- `GetPassword`: `𝕩` is prompt
- `HTML`: displays html (`𝕩`)
- `Text`: displays text (`𝕩`)
- `Clear`: clears the display
- `Image`: displays image (`𝕩` of rank 2 or 3, `0.0`-`1.0` float values)
- `Audio`: displays sound (`𝕩` of rank 1 or 2, `¯1.0`-`1.0` float values) with sample rate of `𝕨` or `audioFreq`
- `audioFreq`: 44100
### cell magic
Start a cell with `%` to use magic. They need to be on their own lines.
#### Don't print the final result
```
%r
```
#### Use a REPL function for the cell
```
%use Func
```
`Func` needs to be able to accept a (multiline) string as input and output a value.
`Func` also needs to be able to evaluate `"•fmt"`.
#### Display the final result as an image
```
%image
```
Calls `•jupyter.Image` on the final result
#### Display the final result as an audio
```
%audio
```
Calls `•jupyter.Audio` on the final result
## todo
- [x] running on docker
- [x] running on actual machine
- [x] support for jupyter classic
- [x] basic syntax highlighting
- [x] input method
- [x] [support](https://github.com/vylsaz/jupyterlab-bqn) for jupyter lab
- [ ] Rewrite It In BQN™
maybe (big MAYBE)
- [ ] plots
- [x] image
- [x] audio
- [ ] widgets