mlochbaum / BQN

An APL-like programming language

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:bug: Grade Up/Down Broken

codereport opened this issue · comments

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=

Was I supposed to post this issue to CBQN?

It's returning the correct thing - an index into the original array, for each element of a sorted array. ⍋⊸⊏ 1‿2‿5‿2‿3 is how you'd use it to sort the array.'

(fwiw you can ⍋⍋ 1‿2‿5‿2‿3 to get 0‿1‿4‿2‿3)

The JS version has nothing to do with CBQN, so if you run it online and get the same results you should file here. However, I can confirm that this is the expected result. The Grade documentation discusses dzaima's ⍋⍋ suggestion in the "Ordinals" section. You might also check against APL, which has the same definition (adjusting for ⎕IO).

🤦 I actually did cross reference with APL but I used a different sequence ⍋1 2 5 3 2. Clearly I haven't used Grades enough to know their behaviour.

Sorry!