mlochbaum / bqn Goto Github PK
View Code? Open in Web Editor NEWAn APL-like programming language. Self-hosted!
Home Page: https://mlochbaum.github.io/BQN/
License: ISC License
An APL-like programming language. Self-hosted!
Home Page: https://mlochbaum.github.io/BQN/
License: ISC License
When I run this code with Explain
also pressed, I get the message ! Error
.
The following BQN code ⍋1‿2‿5‿2‿3
return ⟨ 0 1 3 4 2 ⟩
when it should return ⟨ 0 1 4 2 3 ⟩
Permalink: https://mlochbaum.github.io/BQN/try.html#code=4o2LMeKAvzLigL814oC/MuKAvzM=
Hi, just starting with BQN !
This is a small detail, but I think the documentation for bqn-mode
is outdated, it seems that (require 'gnu-apl-mode)
should be replaced with (require 'bqn-mode)
(since it is was is provided by bqn-mode.el
).
Any plans on adding emacs support? (I sadly don't program in elisp :/)
I apologize if this is not the place for this type of commentary. Feel free to redirect me as appropriate.
I noticed that the use of a macron for a minus sign goes unexplained in the Expressions tutorial (unless I missed it. I did a few searches). For people coming from APL this isn’t a problem but depending on the target audience perhaps it deserves some mention.
I hope you find this observation useful.
Regards
This is the paragraph where that primitive first appears in the tutorial:
So let's break this down. The 2-modifier Under (⌾) has two operands: the left one, -⟜1, subtracts one, and the right one, 2⊸⊑ uses a function we haven't seen before. It uses the right operand to pick out part of its argument, then the left one acts on that part only, and the entire argument, with the necessary modifications, is returned.
Fantastic project, is there a roadmap for this, or milestones, or release tag as milestone?
Sorry for a noob question.
I tried Switch
described on Control flow in BQN on REPL and CBQN:
Switch ← {c←⊑𝕩 ⋄ m‿a←<˘⍉∘‿2⥊1↓𝕩 ⋄ (⊑a⊐C)◶m@}
value ← "double"
v ← 33
Switch ⟨value
"increment" ⋄ {𝕤⋄ v+↩1}
"decrement" ⋄ {𝕤⋄ v-↩1}
"double" ⋄ {𝕤⋄ v×↩2}
"halve" ⋄ {𝕤⋄ v÷↩2}
⟩
and got the following error:
𝕨⊑𝕩: Index out of range
Switch ← {c←⊑𝕩 ⋄ m‿a←<˘⍉∘‿2⥊1↓𝕩 ⋄ (⊑a⊐C)◶m@}
^^^^^^^^
Switch ⟨value
^^^^^^
So something is wrong. I found this one seems to work (REPL):
Switch ← {c←⊑𝕩 ⋄ m‿a←<˘⍉∘‿2⥊1↓𝕩 ⋄ (⊑∘(m⊸⊐)∘<C)◶a@}
Is this OK?
When attempting to run the destructuring example from the docs on blocks:
Destruct ← { 𝕊 a‿1‿⟨b,2⟩: a≍b }
Destruct 5‿1‿⟨7,2⟩
The online REPL fails with the following error:
Unknown character: :
Hello!
The documentation string here under "Insert With Initial" appears unfinished.
https://mlochbaum.github.io/BQN/help/insert.html
Thanks!
If I hover over Fold
, I get Fold \5
, but if I hover over Scan
I get only Scan
, without the helpful tip for ``` to be included.
I tried to fix it but I don't know JS.
Cheers!
The runtime section of the VM docs mention that the +
operator needs to work on two atoms, but I believe this should say "one or two atoms" just like -
since the JS VM fails when the monadic case is not handled.
In the section on assert with a left argument, the output doesn't look quite right. The codeblock
"Message" ! 0
ERROR
⟨∘,"abc",˜⟩ ! '0' # Okay this is not a very helpful printout
ERROR
doesn't produce the same output when you run it in the online REPL, which makes sense since it stops execution after the first failed assertion, but I think the output ERROR
might not be right. Could we split the asserts into two code blocks, then change ERROR
to the result in the online REPL or CBQN?
Tutorials assume (pretty presumptively, really. Disgusting.) that you are already motivated to learn BQN and use simple rather than flashy examples. Documents to induce motivation beyond the README are not yet available.
I'm one of those people who is you know curious but cautious and I need to see bit of beauty to really dig in. Would love to see some wild examples. In particular, the slides in this section of Aaron Hsu's talk struck me and I'd like to learn them in BQN (I don't know APL)
The modifier each ¨
is shown as \1
in the list tutorial, when both kakoune and REPL bindings use \2
.
I have encountered this behaviour a few times when using BQN. I will enter an expression, but instead of an output OR an error, I will see what seems to be a call graph.
For example,
{𝕩⍟0} 3
->
v0=e[1];if(v0===null)err();
v1=e[5];if(v1===null)err();
v2=e[2];if(v2===null)err();
v0=call(v1,v0,v2);
v1={e:e,p:6};
v0=set(1,v1,v0);
v0=O[21];
v1={e:e,p:7};
v0=set(1,v1,v0);
v1={e:e,p:8};
v0=set(1,v1,v0);
v0=e[6];if(v0===null)err();
v1=O[21];
v2=e.p[66];if(v2===null)err();
v3=D[121](e);
if(v2.m!==2)err();v1=v2(v3,v1);
v0=call(v1,v0);
v0=e[1];if(v0===null)err();
v1={e:e,p:9};
v0=set(1,v1,v0);
v0=D[122](e);
v1={e:e,p:10};
v0=set(1,v1,v0);
v0=e[7];if(v0===null)err();
v1=e[10];if(v1===null)err();
v2=e.p[1];if(v2===null)err();
v3=e[4];if(v3===null)err();
v4=e[2];if(v4===null)err();
v2=((f,g,h)=>(x,w)=>call(g,call(h,x,w),has(f)?call(f,x,w):f))(v4,v3,v2);
if(v1.m!==1)err();v1=v1(v2);
v0=call(v1,v0);
v1={e:e,p:11};
v0=set(1,v1,v0);
v0=e[8];if(v0===null)err();
v1=e.p[55];if(v1===null)err();
v0=call(v1,v0);
v1=e[10];if(v1===null)err();
v2=e.p[1];if(v2===null)err();
v3=e.p[119];if(v3===null)err();
v4=e[4];if(v4===null)err();
if(v3.m!==1)err();v3=v3(v4);
v4=e[2];if(v4===null)err();
v2=((f,g,h)=>(x,w)=>call(g,call(h,x,w),has(f)?call(f,x,w):f))(v4,v3,v2);
if(v1.m!==1)err();v1=v1(v2);
v0=call(v1,v0);
v1={e:e,p:12};
v0=set(1,v1,v0);
v0=e[6];if(v0===null)err();
v1=O[21];
v2=e.p[66];if(v2===null)err();
v3=e.p[3];if(v3===null)err();
v4=e[11];if(v4===null)err();
v5=e[12];if(v5===null)err();
v4=list([v4,v5]);
if(v3.m!==1)err();v3=v3(v4);
v4=e.p[115];if(v4===null)err();
v5=O[21];
v6=e.p[7];if(v6===null)err();
v7=e.p[48];if(v7===null)err();
if(v6.m!==2)err();v5=v6(v7,v5);
v3=((f,g,h)=>(x,w)=>call(g,call(h,x,w),has(f)?call(f,x,w):f))(v5,v4,v3);
v4=e.p[115];if(v4===null)err();
v5=e.p[42];if(v5===null)err();
v3=((f,g,h)=>(x,w)=>call(g,call(h,x,w),has(f)?call(f,x,w):f))(v5,v4,v3);
if(v2.m!==2)err();v1=v2(v3,v1);
v0=call(v1,v0);
return v0;}
and 2◶"abcdef"
->
v0=e[1];if(v0===null)err();
v1=D[120](e);
v2=e[5];if(v2===null)err();
v3=e.p[115];if(v3===null)err();
v4=e[1];if(v4===null)err();
v5=e[4];if(v5===null)err();
v6=e[2];if(v6===null)err();
v4=call(v5,v4,v6);
v2=call(v3,v2,v4);
if(v1.m!==1)err();v1=v1(v2);
v2=e[2];if(v2===null)err();
v0=call(v1,v0,v2);
return v0;}
Am I missing a simple symbol for echoing / printing in these situations? I would love some clarity here.
Why can't I use the flying saucer Emojii, in the language for flying saucers!?
I want to be able to sprinkle my hieroglyphic BQN code, with emojii. ASCII begone! camelCase
getouttahere.
This would be properly fun (even if discouraged 'officially').
Can it be done? You're using UTF-16 already, right? Most terminals, VIM, etc, support it no problem. According to this, they're encodable using UTF-16.
You know you want to! (or at least, I certainly do!)
So at the very least, Unicode support for variable names?
Python doesn't support emojii variable names however, and...although I'm not sure this is good for the argument, but Javascript does. More interestingly, so does Swift:
If I try to run this code, I get the error message s is undefined
.
is https://mlochbaum.github.io/BQN/keymap.html correct and up to date?
I'm doing https://github.com/jackokring/qmk_firmware/tree/master/keyboards/dz60/keymaps/jacko_keys to make a BQN pair of key layers.
I noticed ⍎⍕↙↖⍳ are marked as both possibly removed but also possibly going to be added.
I feel the result should be 1, unless I'm missing something...?
I did test with the left argument set to 1, 2, 4, 5, 6, 7, and 8, with correct results.
In Editor Support page, mention the BQN extension for VS Code.
For example, https://github.com/topics/apl.
I made @jackokring/majar as a simple language so far. It has no numerics yet. A nice embedding might be a fun project for me sometime.
It does have a nice error handling mechanism though.
People with deuteranomaly /master/community/aoc.md see this:
Never rely solely on color to distinguish visual elements.
Hello, I noticed the following when working on a documentation major mode for emacs. I'm unsure if its a bug, or intended due to some floating point standard.
Consider:
9 ⋆ 3
729
But:
3 √ 729
8.999999999999998
and
0‿1‿2‿3 √ 729‿729‿729‿729
⟨ ∞ 729 27 8.999999999999998 ⟩
So sometimes √
returns a float even though 729 has a integer cube root.
The next lowest natural number that has both an integer square root and cube root is 64, notice that we get integers back rather than floats:
0‿1‿2‿3 √ 64‿64‿64‿64
⟨ ∞ 64 8 4 ⟩
For what its worth numpy
only returns a floats, although offset in the opposite direction:
Python 3.8.2 (default, Feb 26 2020, 02:56:10)
>>> import numpy as np
>>> np.cbrt(8)
2.0
>>> np.cbrt(64)
4.0
>>> np.cbrt(729)
9.000000000000002
The example here would be easier to grasp with other numbers. 4^2 == 2^4
which doesn't immediately show the intent of the Swap
, because the output is the same, with or without the Swap
. Could you take 3
or 5
instead of 4
?
I'm a little confused at how to get BQN up and running on Linux using CBQN, I don't know what I'm reading wrong or if there is something I'm missing. How am I supposed to get this up and running. I'm on WSL Ubuntu if that is any help. I'm am really interesting in this language and notational/array based syntax and semantics as a whole and any help would be greatly appreciated.
Should this be “multiply”?
for example if you multiple two Int8 arrays then the results will wrap around rather than increasing the type
In Short: What do You think about setting up something similar to scheme's SRFI system?
In Long: As I am (slowly) getting my feet under me with BQN and array programming in general, I was looking on ways to (eventually) contribute. On the community page, one of the things mentioned is the need for libraries to be written.
As a Lisper, I've greatly enjoyed the structure and reliability that SRFI libraries have added across implementations. Because the actual requests are abstracted away from code, they are both easier to understand and testably conformant to a standard. If I use SRFI-1 on Guile Scheme, it will work (nearly function for function) on Chez Scheme or Chicken.
Especially since BQN is so new, now might be a good time to allow for a system like this, where people might submit proposals for systems they would like to have in BQN according to a template, feedback from the community might be gathered, and then a standard for a specifically-named library, independent of implementation, might allow people to implement a consistent programming experience.
Yes, I could just set something like this up alone, but I both wanted to see what the reaction was here first and wanted it to be more than a personal project.
WDYT?
I am very new to APL/BQN and am very enamoured with your project, which, after many months of hunting down which programming language I was going to learn next, finally your pitch has seduced me 🛸. Very exciting.
I have one comment though. With the increasing growth of probabilistic programming languages and libraries, and with the huge importance of random number generation in machine learning, would it be worthwhile to extend the BQN symbol set with random number primimives, as opposed to the keywords currently proposed?
It seems to me that an even larger part of mathematical and statistical programming in the future will deal with randomness and this might help the concept of the notation as a tool of thought?
Am I right that Dyalog APL has ?
as a symbol for "roll", for example? I don't seem to be able to find it in BQN.
In the online REPL, this code produces an error that just looks like nonsense.
3↑2‿2⥊↕4
×: Arguments must be numbers
CBQN produces this output:
3↑2‿2⥊↕4
┌─
╵ 0 1
2 3
0 0
┘
This document links to a page that does not exist: https://mlochbaum.github.io/BQN/doc/train.html
The broken link is: https://mlochbaum.github.io/BQN/doc/tacit.html
In APL I would write something like 3 4 ⍴ ⍳12
to get a 3x4 array of values from 1 - 12. In J it would be something like 3 4 $ i. 12
(which would give 0 - 11)
In BQN, I assumed it would work similarly 3 4 ⥊ ↕ 12
but I must be doing something incorrect. I have tried a number of blocking for presidence, but nothing quite works.
Anyway, I'd love to know what I'm missing. I'm loving bacon so far :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.