It's time to announce BQNcrate⊔˜. Like APLcart, for when you would rather have BQN.
I'll be translating more entries from APLcart over time. After removing the system and dfns stuff, there are about a thousand left. Some of them are pretty long and could take a while, though.
Given two matrices A and B with the same number of columns I would like to know if there are any rows which are the same in A and B. In Dyalog APL I can use the function split like this:
(↓A) ∊ ↓B
Is there a way to calculate the same result without the split function?
@TessellatingHeckler The compiler now produces source indices for bytes (per-opcode might make more sense, but per-byte is much easier). You can enable them in cjs.bqn by passing a -i flag before any other arguments.
I'll see if I can get the JS runtime to use them for error messages; it's trivial for a bytecode interpreter but a little harder for a transpiler since it doesn't naturally have access to the current bytecode index. It needs to produce code that sets a source index.
@Marshall That's interesting! I've done a git pull and cjs.bqn -i r and the output looks the same, where do the source indexes appear / what do they look like?
@TessellatingHeckler Yes. Although for r.bqn the relevant source is actually the output from pr.bqn and not r.bqn itself. You can get that source by sticking •←ref at the end of pr.bqn and running it.
It's probably not too hard to build a back-translation to indices in r.bqn. E_proc and E_redef would have to return the length of each character in the output instead of actually doing the substitution.
using the indices info for dzaima/BQN errors: https://dzaima.github.io/paste/#0vVPLSsNAFN3PV1y7k17bmaoLgxZq0qKgba26LdS0SrBNNMaFqOBCah@K1geCIPWJioJLF6KL@ifzBX6Cd2x1oQU3xSRnTu7NuXdmzhAAkPVbQ5dbe4buFBasfE5WN42UilPLtqzfgSzuKQ29yo2L0cKC43q@QCBIz5zlBYcn4sGsGZhZtH0MAIyUb/X99OjOL8tXitf7fGzUNh3XzZlexJ1birqu42owu2ybnuXYQDowM/l8LgsFx85kLRWsUCs/9uDbMb49oawWUZZOUG5XCCVcw8YDJW4ItziIYZTlMxyi8YpwTTgnXKCsXBKIr6ms9Eq5HZTFGuEAIRaJCMDGPTaeqecLyp0yBmmsEvapbJdQU7JhkhHpTTKaFCWSlUPsUlv@40pDJy81YfeSlzHnWa/G6ED0xHjSUu59Ocoaj3/f7MchsdZCiTkHHlJTJacnRyCkgfrIY8CFShqxuAGCMoK3VhSLi4SKB1pxKjoVZ@Gw6P/sJGAsoSeAf9Y0E1@thaYOv0…
@Marshall not much i had to do - just create a new token type and write the indices in
(the bytecode is there (with a weird pointer) because the source of the full created blocks is null, and i report both the containing block and specific pointer. though probably a bytecode pointer just pointing at the start of the function is pointless)
where is the compiler code, is it cjs c from c.bqn? I can't build it, and currently fails trying to [math]::floor() a function, might be able to track back from here to the code
@TessellatingHeckler ./cjs.bqn -i c works for me. If you override your runtime with its result, doing lastLine[errorOffset] should give you the index of the error in c.bqn (that's assuming the error isn't in the runtime, at which point it gets a lot more complicated; getting a full stacktrace of all the offsets would also be helpful)
@Adám 0⍴⊂2⍴0 is a SingleItemArr not an EmptyArr; and 1e7⍴⊂X is a SingleItemArr too, so the whole expression only takes a couple hundred bytes. Forcing proper efficient duplication of all the ⍬s is the hard part
(remember that ⊢¨1e7⍴⊂⍳1e6 takes "only" 50MB as ⍳1e6 isn't duplicated, so why would ⍬ in ⊢¨1e7⍴⊂⍬ be?)