@Adám Ok, let me ask the question a different way -- given that the APL bits should work, is there anything in the jupyter-kernel that might serialise output differently or otherwise make different assumptions than a normal session? The reason I ask is that the cultivation examples on the topic, when run in jupyter, look quite different.
Here's my 'normal' session:
{⎕←'Started waiting',⍵,'s' ⋄ ⎕←'Elapsed:',(⎕DL ⍵),'s'}&¨0.6 1.2 1.8 ⋄ ⎕DL 1 ⋄ ⎕←' Unrelated stuff'
Started waiting 0.6 s
Started waiting 1.8 s
Started waiting 1.2 s
Elapsed: 0.611686 s
Unrelated stuff
Elapsed: 1.231548 s
Elapsed: 1.841549 s
Here's jupyter:
Started waiting 0.6 s
Started waiting 1.8 s
Started waiting 1.2 s
Elapsed: 0.610196 s
Unrelated stuff
Huh, that seems a bit impossible. You get the starting message but not the ending message. Maybe the kernel doesn't handle incoming print requests right, after the code has terminated. TIO also suffers from this: Try it online!
Adding ⎕TSYNC⎕TNUMS~0 to the bottom of the request fixes the problem. Maybe the kernel should do that. Try it online!
@Adám Thanks for offering to help with un-dinosauring the code in my APL book. I will take you up on that. I also mis-stated the target audience; I wrote it to help Raspberry Pi users to experiment with APL. Many will be school students but some will be hobbyists or teachers.
Well. Thinking about async/await in other languages, I'd probably expect to have to spell it out, and perhaps it's more of a surprise how the session does not require it. But the difference in behaviour isn't ideal, I guess.
@Adám I was testing my solution on problems.tryapl.org/psets/… and got this message: "Submission caused SYNTAX ERROR with (' this is a test ') as right argument"
Looks like it's still using the old test case with missing spaces?
I have a vector of character vectors, and I want a boolean to tell me which vectors start with three backticks. I can do it with each, but I can' t get rank to give me a simpler solution.
I don't even have to do the ↑ in RickedyPs solution, as the data comes from a native file and I can just as easily get a matrix as a vector of vectors. And it's old skool - the way I'd have tackled it in the 80s.
('`'∧.=3∘↑)¨ is how I wrote it a while ago. On nested vectors
I found myself using highly nested structures when I parsed markdown. A more flat approach would be awesome - although particularly difficult, I imagine
@rabbitgrowth Not something intrinsic. I just use the term to mean using multiple regexes where the first one gets replaced with itself. Not sure it makes sense here.
@xpqz You can combine the first and last with |
pattern_for_spaces_to_keep ' '⎕R'&' '' uses an exception pattern, and then removes all other spaces.
Sure. I just like the fact that you can express that sort of thing as multiple patterns on the "apl side" rather than in the regex. It's a cool feature.
@RomillyCocking I have a nice expression {⍵∧⊃1 = 1 0 ¯1 +.⌽ ⊂⍵}∘{((3=1⊥⊢)⌺(⍪3 1))'`'=⍵}, from here you turn off the last 1 - if the sum of the result is odd. And do some kludging for ⊆ or ⊂ then you have an implementation of inline triple backticks that matches the markdown spec
@Adam discussion earlier took me back to the traditional 'count leading backticks' solution, which I like as a good example of array vs procedural thinking.
@awagga I think you're solving a more complicated/general problem than mine.
I have a feeling backticks could be implemented in a way simpler/shorter/more elegant than my approach. But I am bad at using booleans to their full extent
@Richard Regex is generally slower than array operations (especially Boolean ones), but when performance isn't critical, and the problem is a good fit, I still use them. However, if you don't use regex features, ⎕R will use fast array code under the covers.
Similar to some of the other functions, but at least for me slightly faster than xpqz's tacit function and over 40 years old: dl.acm.org/doi/10.1145/602312.602317