APL Notes: BQN Mistakes
  1. Shroedinger's namespace?
  2. I said nothing, but why are you doing nothing?!
  3. You might not need the bind in x⊸F¨

Shroedinger's namespace?

Can you make sense of this program and its output?

Node ← {𝕊⟨p,d⟩: { at ⇐ p ⋄ dir ⇐ d }}
What ← {𝕊 node: {•Show 𝕩 ⋄ Node ⟨node.at+𝕩, 𝕩⟩}¨⟨1‿2, 3‿4, 5‿5⟩ }
a‿b‿c←What Node ⟨0‿0, 0‿1⟩
•Show ⟨a.at, a.dir⟩
•Show ⟨b.at, a.dir⟩
•Show ⟨c.at, a.dir⟩
output:
⟨ 1 2 ⟩
⟨ 3 4 ⟩
⟨ 5 5 ⟩
⟨ ⟨ 0 0 ⟩ ⟨ 0 1 ⟩ ⟩
⟨ ⟨ 0 0 ⟩ ⟨ 0 1 ⟩ ⟩
⟨ ⟨ 0 0 ⟩ ⟨ 0 1 ⟩ ⟩

I was baffled by this to the point of starting to report it as a bug, but there's nothing strange going on at all - it's just very long habit of reading programming languages wherein node and Node must have one of the following relations:

  1. completely unrelated
  2. completely identical

In BQN, they're the same value in differing grammatical cases - one a subject and the other a function.

That, plus variable shadowing, results in the namespace created by Node ⟨0‿0, 0‿1⟩ becoming a local variable named node in the What function, where it's used first as a function (where it's simply the constant function, returning itself) and then as one of the ignored parameters to itself.

I said nothing, but why are you doing nothing?!

Consider:

   @ {•Show 𝕨}´ ↕5 ⋄"---"
4
3
2
1
0
"---"
   · {•Show 𝕨}´ ↕5 ⋄"---"
3
2
1
0
"---"

In the first case, @ is used as a visible don't-care value, but BQN also has · (Nothing). Could that be used as a superior don't-care value?

No. Following rule 1 at that link, this is equivalent to {•Show 𝕨}´ ↕5

A mistake that would lead you to expect this to be equivalent to the following 'expansion', is to think of Fold (´) as syntax that applies the provided function. It's a 1-modifier, taking a function and returning a new function. It's that new function that takes Nothing as its left argument and which therefore runs as if called monadically.

   0 {•Show 𝕨} 1 {•Show 𝕨} ·
Error: Can't return Nothing (·)

You might not need the bind in x⊸F¨

Compare:

1⊸+¨ ↕4


1+¨ ↕4