@Adám lots of copy-pasting code around and the clash with ctrl+a/ctrl+c/ctrl+v has driven me to install your alternative APL keyboard, and it's much more forgiving of ordinary shortcut combos!
@TessellatingHeckler Of course. AltGr is actually intended for alternate graphemes. I just wish I could get "the people in charge" to try it. They stubbornly refuse, while pretty much every not-in-charge person that tries it, loves it.
@TessellatingHeckler The Gr actually was for Graphic in the very oldest of days, i.e. for typing line drawing characters. True to that spirit, AltGr+Shift+S, followed by a number (or .) will draw lines. This is 1,5,6: └─┤
@TessellatingHeckler (just to format integer vectors and 2D matrices like that takes 125 lines of XML containing 5857 characters, over half of them indentation spaces)
@TessellatingHeckler Oh, no, I misread. So what did you mean by a huge mismatch between how APL handles arrays and how PowerShell loves to unroll them?
@Adám 3D arrays come out as System.Int[,,], 4D as System.Int16[,,,] etc. up to 15D. I haven't added any code to print them because it would be a big copy-paste job, and I want to settle on some understanding of boxing and nesting and maybe not printing too big for the screen - and probably offloading the code from PowerShell to a C# helper for speed
also I need to pad out to the width of the widest number in the array, and powershell can't find that easily, but C# + Linq could
@Adám well, APL has an array as a single thing, and then does implicit maps over it. PowerShell does not do implicit maps, but it still wants to be able to send multiple things down the pipeline (e.g. a directory listing into a "move-file" command), so it tends to gather results up into an array, then unroll the array and send the results down the pipeline one at a time
so if I want to write PS C:\> dir | ⍎ 5 ↑ | measure-object and have it count 5 things coming out, then my APL side needs to emit 5 things separately, not a vector of 5 things.
if I want to write ⍎ ⍳5 and have measure-object count 5 things, they need to be emitted separately
if I want to write ⍎ ⍳5 and have a single Int16[] array, it needs to be emitted as a sinlge thing, but then when PowerShell tries to format it for display, it sees a collection and does a second round of unrolling to show the items in the collection, and the structure is lost
APL is built for handling arrays without destructuring, PowerShell is built for handling them by destructuring.
so to get that formatting working I need to ⊂ once so when powershell unrolls it into the formatters there's a nested array there, and ⊂ again so that the formatters unroll it into an int16[,] and type-match on that and run my code
@TessellatingHeckler (and that array shaping is Dyalog bridge magic)
@Adám keyboard shortcuts used to be a poweruser secret, now every program has tons of them, every key is so overloaded I'm surprised there aren't more mechanical keyboard people pushing for twice as big keyboards - at least going back to F1-F24 if not a lot more
@Adám do you have any idea if it's possible to have the .Net Bridge open a persistent session to Dyalog?
@TessellatingHeckler F13–24 is simply Shift+F1–12. The series continues with F25=Ctrl+F1, F37=Ctrl+Shift+F1, etc. until F96=Ctrl+Alt+Shift+F12. Do we really need more‽
@TessellatingHeckler a dedicated APL hardware key would be nice. (Microsoft managed to get ⊞ and ▤ added as a dedicated keys)… Yeah, a set of dead keys for all the accents would be nice.
@TessellatingHeckler Any reason you post screenshots instead of pasting plain text?
@Adám actually this makes me realise (sadly) that it would be much easier to make the cmdlet in C#, with a wrapper, and have that hold an APL class instance open which just has a simple evaluate method
@TessellatingHeckler Personally, I don't care, but if someone wants to play around with what you wrote, it is much easier to copy plain-text. Also, some have slow connections or imgur blocked.
@TessellatingHeckler I should just do that; it's not like there's much code - 120 lines of code and 100 lines of comment. Just so attached to implementing the cmdlet in APL.
@marcellothearcane See, that wasn't so hard, was it? I think ⌽ is one of the most mnemonic symbols in APL. Can you, given that string and 'l', generate a Boolean mask (a list of 0s and 1s) that indicates where 'Hello world' has *"l"*s?, i.e. 0 0 1 1 0 0 0 0 0 1 0?
Cool. I'm looking forward to seeing where this leads. I, for one, am excited about APL integrations. I'm working on a an online execution engine, so you can send APL expression requests and get a result back. It'll include the possibility of sending a state too.
@marcellothearcane Sure, that'll work. You can also use the simpler 'l'='hello world' since APL uses = with the obvious meaning (assignment is ←). Now can you use that to count how many ls there are?
@marcellothearcane Interrupt what? Your exploration of APL is the most on-topic content possible for this room.
@TessellatingHeckler I find that confusion strange. = should be pretty obvious as being the "equal" comparison (which is commutative). ∊ should be well known as meaning member-of, i.e. the argument being tested is on the left, and the look-up array is on the right. ⍷ is the only "new" symbol, so it has to be the special array look-up, with the same order of arguments as ∊.
then 'EL'∊⍨'HELLO' 0 1 1 1 0 'EL'⍷'HELLO' 0 1 0 0 0 both of these do *something* with a vector on both sides, but from the 0 1 0 1 pattern there's no hint what except by manually confirming they're an unwanted bit pattern
it means I end up trying both ∊ and ⍷ both ways round - especially when it comes to trying to avoid () and using trains where the data can't be written the other way, commute needs to be used
@RGS if the words were variables and I didn't know what the words or the characters were in advance, I would just do left ∊ right and get 0 1 0 1 0 and have no hint whether that was the thing I wanted to do, or the thing I'd got confused with
@marcellothearcane Right. Now you found out that you can sum with +/ but really you can use any dyadic (two-argument) function instead of +, even logical AND: ∧
@TessellatingHeckler ah ok, so it feels like you are saying something like this: by just trying ∊, ∊⍨, ⍷, ⍷⍨ with arbitrary strings it is difficult to understand which is which, if you don't know already. But I'd argue that reading the description, or having a go with your own examples, it becomes pretty easy to understand which is which
@Adám my dad has been easing into C++ to use with an Arduino recently, and he just got "is string a palindrome?" working yesterday! I'm so pleased about it. He's been an electronics guy for years, worked in IT, but avoided code, and now he has an envelope covered in string indexing offsets.
@TessellatingHeckler But why do you need to resort to ^^ when the glyphs read so readily? ∊ is "member(s) of", ∊⍨ is "contains", ⍷ is "appears as a sequence in", ⍷⍨ is "has the sequence".
You may want to learn that you can have multiple statements on a line by separating them with a diamond ('cause diamonds are unbreakable): S←'racecar' ⋄ ∧/ ⌽S = S
@Adám that's the mathematician in you speaking; the glyphs read "e" and "e commute". And what's easy or memorable about 'ana' contains 'banana'? I'm OK as far as 5 ∊ 1 2 3 4 5 but 4 5 6 ∊ 1 5 6 is much less clear
@marcellothearcane That'll be the next step, but for now: Every APL function takes everything (until the end of the line/statement/parenthesis) as its right argument. So in your code, ⌽ takes 'racecar' = 'racecar' as its argument, while you intended only 'racecar'.
The simplest form of function uses curly braces around its statement(s) and the right argument is represented by the right-most letter of the Greek alphabet, omega: ⍵
@Adám after thinking about it, i think i'd prefer a∊b to have been b∋a. Of course then there's the problem of ⍷ not having a reversed counterpart (in which case it'd still keep its argument order)
@Moonchild If the result begins or ends with a space (or if it has multiple lines), then switch to block mode. Alternatively, you can just stick to block mode always.
Errors could be inline. That'd allow differentiation too.
@marcellothearcane Yes. That's a "remove spaces" function. Can you put it all together to a single, stand-alone palindrome checker function?
@Moonchild I don't get it. However, now I notice that SE doesn't allow all-space/newline messages, so I guess in that case, you could respond shape⍴' ' inline.
CMQ: Does anyone want to assist me with scoring the competition's phase II?
@marcellothearcane If you assign the result of ((' ' ≠ ⍵)⌿⍵) (which btw doesn't need an outer parenthesis), you can use that variable later, and avoid the double work.
@marcellothearcane On the right, you don't need parentheses, but on the left, you do. Otherwise that left-most ⌿ sees ⍵=⌽(' '≠⍵)⌿⍵ as its right argument, instead of just ⍵.
@marcellothearcane APLs function evaluation is right-to-left, i.e. 1+-2×-5+1 is 1+(-(2×(-(5+1)))), so you can only freely remove parenthesis which continue to the end of the expression
@Moonchild Turns out replying with a block doesn't work. You'd have to @id instead. And then the @id should just be a separate line at the top, prefixed with 4 spaces.
@Adám that could work. Problem is, the reply wouldn't be linked to the actual code result, and given ratelimiting there could be more messages in between the reply message and the result message
@Moonchild True. I'd just go with the @id since it usually won't be confusing, even if a user enters a second expression before the bot responds. Does the bot handle requests sequentially or in parallel?
@Moonchild Right, leading too. That isn't terrible. But if the result is all-blank (or empty, which is a subset of all-blank, no?) then you can maybe return shape⍴' ' as an inline message?
@marcellothearcane TryAPL isn't very good at pointing out where your issue is. A real offline APL system does a much better job. You should be able to download one here.
@marcellothearcane If you show me what you've got, I can guide you towards the solution.
@Moonchild Why do the no-result assignments cause empty lines in the output?
@marcellothearcane Well, that's perfect. To make it a function, just remove the initial assignment of B, use ⍵ instead of B, and put braces around the whole thing.
@Moonchild What do you mean regarding the prototypes?
@marcellothearcane Some tricks: ≡ checks if two arrays are identical, so you can write A≡⌽A instead of ∧/A=⌽A and ~ is the set subtraction function, so ⍵~' ' will remove spaces from ⍵.
@Adám I'd be interested in helping score Part II, though I won't be free until ~30th, and then I'll have only free time, too much! What would that look like? I'm super surprised we'd be allowed to help since some have submitted sections, though!
Also, that's the same for the bit re: APLcart I said I'd do ages ago. Still in Europe from studying abroad, so still trying to minimize time on the computer and maximize time outside!