« first day (2101 days earlier)      last day (850 days later) » 

08:48
So suppose I'm solving a sudoku, I can index the rows like this: sudoku[n;] and the columns like this: sudoku[;n]. Is there an easy way to index the 9 3x3 squares?
sudoku[⍳ 3 3] gets me the top left corner, but I don't know how to modify this iota to offset it
rowoffset columnoffset∘+¨
so ro co ∘+¨⍳ 3 3?
Yes, or sudoku[3+⍳3;6+⍳3] for the last 3×3 in the middle row.
that's honestly more legant imo
thanks
Or you could drop: 3 3↑3 6↓sudoku
08:51
hmm
Or rotate: 3 3↑3⊖6⌽sudoku
now you're just flexing
Or mask: (3/0 1 0)⌿(3/0 0 1)/sudoku
09:35
I really like the mask, because it generates a pattern
it's easy to visualise
10:34
No stencil love? :P 1 1⌷⊢⌺3 3⊢sudoku
Did you try that? It doesn't work.
⎕←1 1⌷⊢⌺3 3⊢9 9⍴⍳81
@B.Wilson
0  0  0
0  1  2
0 10 11
Ah, I always forget that I have ⎕IO←0 locally.
Uh, it still doesn't work, as it starts one step to far north-west.
⎕←2 2⌷⊢⌺(2 2⍴3)⊢0,0,0⍪0⍪9 9⍴⍳81
10:42
@Adám
 1  2  3
10 11 12
19 20 21
⎕←2 2⌷⊢⌺3 3⊢9 9⍴⍳81
@B.Wilson
 1  2  3
10 11 12
19 20 21
OK, now try getting the middle square!
⎕←5 5⌷⊢⌺3 3⊢9 9⍴⍳81
@B.Wilson
31 32 33
40 41 42
49 50 51
10:46
Just SE by 3 3, no?
SE?
Southeast.
Sure, but you had to go 3 steps SE instead of 1 step, because you generated way too many sub-arrays.
Yeah, extraneous 8X overhead does seem subideal :P
And easy to fix with an additional row in the right operand.
10:52
You're too fast! I just went and read the Stencil docs and then realized exactly what you were doing above. Why the zero padding though?
> Rectangles are centred on successive elements of Y
Hrm...
Yeah, we need a way to specify that. Without it, we have to discard the outer ones.
11:18
Man, Roger Hui always seems to deliver: dyalog.com/blog/2020/06/towards-improvements-to-stencil
Really wish I could have met him.
11:30
@Adám Thanks for sharing. Interesting that Git and SVN live together. Are they mirrors of each other or used on separate projects?
Separate things. new open source things use Git. Old stuff uses SVN.
 
2 hours later…
13:42
you have open source things?
Dyalog's open sourced a hefty chunk (maybe all?) of its code bar the interpreter itself. It's a very useful resource to learn from when it comes to "industry strength" APL.
14:01
i saw this code in the tutorial: ⍉2∘⊥⍣¯1⍳2*3. i dont get it, how can you repeat (power) something -1 times?
That's an inverse.
Or "magic" if you like.
A lot of APLers find that a clever feature (I detest it).
That particular inverse is useful though.
      2⊥⍣¯1⊢976
┌→──────────────────┐
│1 1 1 1 0 1 0 0 0 0│
└~──────────────────┘
Converts to binary, using the smallest number of bits required.
i dont get why theres a ⍣ there tho
It's consistent with mathematics.
what purpose does it serve?
power-of-minus-one is one-over or inverse.
It magically lets you solve equations involving a function and the answer
What argument was a function applied to in order to give the answer?
14:15
ah i think i get it
how does it determine that tho (the inverse)?
brute force?
That's the clever bit. In many (not all) cases, the interpreter can reverse its built-in formula for combinations of the primitives.
However, it can't do so for dfns you write. A proposed extension (obverse) would let you define forward and back versions of your own functions.
interesting
Maybe :)
I find that beyond a few well-known ones (like the binary one above) it quickly becomes hard to follow.
Inverse is very handy, too:
      ⍸⍣¯1⊢1 2 5
┌→──────────┐
│0 1 1 0 0 1│
└~──────────┘
Someone here said that Dyalog views inverses as 'Easter eggs' to be discovered, rather than documented. This contributes to my dislike of inverses, tbh.
I don't think that's true. They have been called party tricks, because it's generally not a good idea to use them in production.
It would be a lot of work to document the (useful) inverses
@awagga Documentation is a lot of work.
14:23
I agree with the sentiment though, it's a shame
 
3 hours later…
17:26
k so ive been going through some examples. this one is for AoC 2016 day 6: {⊃⊃⍵[⍒⍵[;2];]}¨{⍺,≢⍵}⌸¨↓⍉↑data. could it be made any better/clearer?
the sorting by column was stolen from aplcart
You sort the entire range only to get the first element. You could simply compute the grade (as now) and get the first index.
You could also fuse the two loops into one, e.g. by using a 2-train ({⊃⊃⍵[⍒⍵[;2];]}{⍺,≢⍵}⌸)¨
If you want, you can make {⍺,≢⍵} tacit as ,∘≢ but I'm not sure if it will impact performance.
@Sʨɠɠan Btw, you could submit such questions to CR.SE
tbh to me {⍺,≢⍵} is clearer
@Adám i know, but i dont think its worth for such a small snippet
@Sʨɠɠan Yeah, it's a style thing.
@Sʨɠɠan It'd be kind of funny, because people usually submit walls of text, but APLers ask for review of single-line programs.
lol
thanks, time to do other aoc challenges now
Sure thing. Are you aware of apl.wiki/aoc?
17:34
no
does it have spoliers
ah fortunately not right in front of you
It is list of links to repos with published solutions. You can publish yours too and add to the list.
17:47
is there any way to apply a function on a vector rather than doing {⍵[1]<function>⍵[2]}?
⊃function/Y?
ah forgot folding
ty
Did you search APLcart, btw?
Right. The missing keyword is vector which I'm adding now.
17:54
i solved 2021 day 1 in a few mins compared to the half hour it took me with a python solution last year
How long have you been programming APL now?
2 days i think
or 3
How long had you been programming in Python back then?
first message in here was about an hour after i started:
Oct 24 at 15:22, by Sʨɠɠan
i love how you can reset the index origin in apl
@Adám erm... lets see
i started when i was 11, im 15 now...
learned python a year after starting to program...
3 years
I don't know how you do it. I think I've never experienced anyone picking up APL as fast as you.
18:00
how can i tell stencil to not overhang?
You can't :-( but you can pad with extra elements and discard the first sub-array(s).
I know. That's why I have a proposal to fix it a bit.
okie. aoc 2021 day 1 part 2: +/(</⊢)⌺2⊢¯1↓1↓(+/⊢)⌺3⊢data
any comments?
(</⊢)⌺2 is 2</
¯1↓1↓(+/⊢)⌺3⊢ is 3+/
+/2</3+/data should work.
18:07
waiit whaat?
reduction has a window option?
Yes, left arg is window size, but step size is always 1, and it cannot overhang edges.
thats exactly what i need
learn something new every day™
@Adám indeed it does work
:-)
19:03
@Sʨɠɠan Next year, you could participate in the APL Problem Solving Competition. Maybe you'd eventually be interested in an APL internship? Many companies that use APL are desperate for more APLers…
19:14
what is the APL Problem Solving Competition?
as for an internship, i wont until at least im out of high school :P
In general, you can find out about things that relate to APL on the wiki, e.g. apl.wiki/APL_Problem_Solving_Competition.
mhm thanks

« first day (2101 days earlier)      last day (850 days later) »