The idea is treat the image as an 1D array and compute the offsets to do the update. It takes long on slightly larger images. I find the idea is close to Levenshtein distance, but "fold"/reduce get WS FULL on large images.
Argh, the story is too complicated to explain, but suffice it to say that I have spent hours searching for a single bug in the double-arrow function definition syntax and it all ended up with a stupid error where I had hardcoded the wrong namespace.
In any case, my current design is such that functions declared with ∇ are global, and if they use ⇐ they are local.
@LdBeth Shouldn't a be defined in terms of y, not x? When a matrix is ravelled, the rows stay together, and y is the length of a row, so it will be the distance between a position and the same one in the next row, that is, between an element and the one above or below it.
@LdBeth You're saying here that you switched to recursion because reduction was using too much memory, right? The ∇ here is a tail call, so I see why it doesn't cause a WS FULL. But ⊃p/(⌽⍳s),⊂,⍵ (untested) should do the same computation without saving intermediate results. What did your reduction look like?
There's also a big performance problem with p: it can't change ⍵ in place because it doesn't know that it will never be reused (Dyalog doesn't do lifetime analysis on variables). I don't know of a way to fix this while keeping a pure functional style, and there might not be one.
What I would do for better performance is make one mutable variable i←,⍵, and modify it with a loop like {i[(⊢(/⍨)(s∘>))⍵+a]+←8÷⍨(⊢-(255×t<⊢))⍵⌷i}¨⍳s.
Personally I find this clearer because the state gets a dedicated variable rather than being passed as an argument. It's not good that there's no indication i will be modified, but you can add a comment.
@LdBeth You can't do multiline code in the same message as normal text; put the code in its own message and use ctrl-k.
@LdBeth Nothing in that statement looks like it should use much memory, so I'm not sure what the issue could be. You could try just changing the last line of your current implementation to see if it has the same problem, but as long as it has to copy the image at each step it'll be just as slow.
@RGS I've found that in jupyterbook, if an APL code cell contains an underscore anywhere, the syntax highlighting is switched off in the resulting html -- have you noticed this?
@KamilaSzewczyk It wouldn't really make sense because a reduction only ever happens along one axis. Some of the functions in towards improvements to stencil could be helpful.
@Adám if it didn't mix, it could be extendable for any nested array with sane sematics. With mixing, the scalar and vector case have very different behavior
@dzaima Ah you mean that the result would have exactly the same outer structure as the operand, only with every simple scalar replaced by an enclosure of the result of applying the function that many times?
@xpqz Aha, I see it. Looking at the tool log, I see a "\booktest\notebooks.ipynb:: WARNING: Could not lex literal_block as "APL". Highlighting skipped." message. It should be a deficiency in the plugin used for the highlighting.
Do you happen to know what they use? If it's open source we could fix it – or at least open an issue about it.
@Adám you can just mention it whenever it makes sense. (though even otherwise i'd prefer no merging. ⌸ in dzaima/APL already doesn't merge, and ⍤ (or rather ˘ in BQN as it's more compact, the ⊢∘ tripling its length) merging is awful every now and then, though it's usually good)
(after finding out how matrix bridge bots get fancy user profiles informing about it being a single bridge, and deciding what to do with usernames (currently every SE user has -se appended to their name, which is ugly), my matrix bridge is probably good to go)
trying to make the JSON for the vscode snippet plugin: https://tio.run/##dVZbbxtFFH73r9i6QGzSJlAuKt4GSJwLKXUS7HCR0rAd787aU69nltlZJyYEFQmlidP0BqVp1VLoRaQqEg8gglRaJPcxD/yH/QX8g/LN2E4aLi/2nG/OnDNzLt/Z06RBIleyUB1uHH36NKDKiprcDaKhJauRS39AgpimD1l@Lj0ec1cxwSHVc@mC8JjPqITk7UlHIPJceiqul81WJZeeoCrCKsylZ4ik@nQ5lx6RxK1RBaHWEbSPIJc@wSpExZJ2zQhVZbwCIcqlSzQkkiihzbq5dF7U65RrCwR7Smo9a9lO6QfUaNOjkTvU5/fnBT8dwya1hz3P8Q9PUSOU4rKCV@X4T66WWIXbhThQLAyaALaL1GWhFC4J7FHWYB51/GR9ZWwxFBweGeAZsUAl0NXrpU9ivMoqCqFs/QPwXGs8EELaBcZZPa5rZDVPWYAb2gWy2MVWfygJqaz3Q3uYe1reMvKoWOD2NGy3f8Tr7VJIuON/NlyORBArapl02Ih2HMQRTq3dPUGjyJqt…
@Adám lol (my client doesn't do font fallback because that means a couple orders of magnitude slower window resizing so i had to resort to viewing that on SE ¯\_(ツ)_/¯)
@xpqz It fixed it? From your original msg I can't understand if you meant any underscore whatsoever or only isolated underscores, but mastering.dyalog.com has underscores in code cells with highlighting – in the middle of the name of variables
@Adám i'd say it's approximately the same level of realness as dzaima/APL. (and ⍩ is only in dzaima/APL, but i'm suggesting it as it can't really be anything else)
What I mean is, the lexer there seems to follow standards that don't match Dyalog's.
And I was wondering how to proceed with regards to that. Adám just said that _←4 doesn't work in APL2 (which is now dead, correct?) and the lexer says it's following APL2's standards.
@xpqz I don't think that's relevant, at all. I don't mind doing that as part of my job, but I also don't want to prevent you from making a (small) contribution to the pygments project.
@xpqz So you removed the reference to APL2 and included the ref to Dyalog?
Hello - in j (or apl, if it's not a builtin and I can try translating) is there an idiom for the coordinates of a boolean in a matrix? i.e. if I have (0 1 0;1 0 0; 0 0 0) I want to get (0 1;1 0) as a result
@C.Quilley Oh, in J that is the case, not in APL. You can implement it as as the copy # of the flattened matrix over the flattened list of all coordinates.
@dzaima I love the comment there, 'I will pretend for a moment that I carefully reviewed your code change, double-checked the primitive functions against the latest APL dialect, and came to the conclusion that your changes are correct and valid. Thanks for the contribution!'
@nathanrogers There's not much reason for symbols imo. It already has lexical scope & closures, and the 2-argument limit means ⊸ and ⟜ are enough for partial application
In computer programming, symbolic programming is a programming paradigm in which the program can manipulate its own formulas and program components as if they were plain data.Through symbolic programming, complex processes can be developed that build other more intricate processes by combining smaller units of logic or functionality. Thus, such programs can effectively modify themselves and appear to "learn", which makes them better suited for applications such as artificial intelligence, expert systems, natural language processing, and computer games.
Languages that support symbolic programming...
github.com/razetime/bqn-vscode BQN snippets and base language configuration and file association complete. (Now to figure out how to expand things automagically)
@nathanrogers still wouldn't call that symbolic programming. It's just ⍎'name' with better syntax (and also ability to assign sanely i guess, but that's been proposed for Dyalog too). Worse yet, that uses dynamic scoping :P
@nathanrogers I don't plan to support symbols, and BQN isn't designed to do any sort of meta-programming. Functions describe computations and can easily be written, passed around, and applied. For example see the document on implementing control structures.
I am terrible with CSS but it feels like the line-height is too short? It also feels like the font being used isn't monospaced – that would explain the misalignment in the bottom right corner of both boxes.
@KamilaSzewczyk It allows you to perform computations on numbers rather than arbitrary data. Roger's generally moved to advocating self-classify which does the same but has the advantage of fixing up some tolerant comparison issues; in APL it's written ∪⍳⊢.
@dzaima oh, in fact it broke exactly the same way as the IRC bot has - I'm writing this from my Matrix client, it appears in SE, but I don't see new messages from SE
@dzaima restarting is always an option, but since it doesn't throw any python errors (i guess i could parse stderr, but i already use it for logging) that has to be done manually. (but a manual restart currently requires restarting the whole thing, which clears the message map which is only in memory, meaning replies to older messages won't work correctly)
"can you find me the longest run of consecutive integers in this vector" vs how do you do that (as in: explain to the computer) are two different questions with different levels of complexity
@rak1507 who knows. those "young people staffing the booth" might not have been programmers at all or in those "few minutes" they might have been busy with something else.
It's also a big jump from "APL was manifestly better than a moderately obscure CAS in the year 2000" to "APL is always better", but APLers sure seem inclined to follow that logic.
@ngn Been thinking there should be a BQN extension available for this table. BQN obviously sees itself as the alien from Alien; from APL's perspective it's probably more like E.T.. For K, Jabba the Hutt?
CMC: Find an array oriented way to solve this "iteration game"
I don't know what this is, and someone asked me what is an idiomatic way to write this in APL, and I don't really know what an iteration game is, thought maybe I'd toss it to someone here who might actually know what that is
The optimization puzzle so far as I understand it is get to f0>= 1000 in the fewest moves