mlochbaum / BQN

An APL-like programming language

Home Page:https://mlochbaum.github.io/BQN/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for flashy examples in docs

qpwo opened this issue · comments

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)

image

It's been a while since I wrote that and it's much less accurate now. The community page links to BQN examples: the most structured are probably Asher's videos, and Rosetta Code and Stack Exchange have a lot of good explanations for small programs.

Aaron's examples mostly translate fine to BQN, although set functions ∪∩~ aren't single primitives so they have to be changed a little. To be honest I don't like these snippets too much (the depth vector one is O(n³); I don't think you'd ever want to construct that matrix). But I do have a documentation section on the ⍋⍋ pattern that he mentions.

APL BQN Alternative
2|+⌿¨⍳12 12 2|+´¨↕12‿12 ≠⌜˜2|↕12
∘.(≢∪~∩)⍨(⌊∘⊃∪⊢)\⌽⍋⍋⌽d (+´·¬∊∾∊˜)⌜˜(⍷⌊`⌾⌽)¨1↓↑⌽⍋⍋⌽d ((+´≠)⌜˜≠↑⟜(⊢<∞«⌊`⌾⌽)¨1↓↑)d
(⍳×/s)≡I∘⍋⍨⍋⍋,+⌿¨1+⍳s (↕×´s)≡⊏⟜⍋⍋⍋⥊+´¨1+↕s

Thank you!