« first day (2228 days earlier)      last day (413 days later) » 

12:07 AM
why the ⍳∘≢∘⍸ ? Isn't that just ⍸
 
 
1 hour later…
1:35 AM
@Adám Directly counting areas felt daunting, so I chickened out:
{m n←2*(⊢,¯1+⊢)x←1+⌊2⍟⍵ ⋄ (n-1)⌈+/x-⌈2⍟m-n+⍳⍵-n-1}
Feel like there is a better spelling of this though.
 
 
4 hours later…
5:41 AM
@SilasPoulson No, ⍸1 0 1 is 1 3 but ⍳≢⍸1 0 1 is 1 2. That said, I think would work too.
 
 
4 hours later…
9:15 AM
today i looked up the vector product in aplcart and was surprised by the repeated code
((1∘⌽⍤⊣ׯ1⌽⊢)-¯1∘⌽⍤⊣×1⌽⊢)
looking at the train-tree in ride, the two sides of the minus-fork were identical, with the exception of the negation of the ones present in the rotate functions. i was wondering: is there really no good way to shorten this in apl? could newer languages like bqn do it? could we make a nice combinator to solve this issue? well, its not really an issue, but it would be neat to have something to make it even more concise. any thoughts?
 
@Slimey Heh, that exact question comes up every once in a while.
How do you like ⊃⍤⊃(1 ¯1)(¯1 1)-.(×.⌽)⊂⍤,⍥⊂ ?
 
9:40 AM
@Slimey Yes, there is a possible "flipover" combinator with the pleasant definition ⛣←{(⍵ ⍵⍵ ⍺)⍺⍺(⍺ ⍵⍵ ⍵)} that would allow -⛣(¯1∘⌽⍤⊣×1⌽⊢) and if we in addition define A∘f to ignore its left argument, we could write -⛣(¯1∘⌽⍨×1∘⌽). Finally, we could define A⍛f as A∘f⍨ and write -⛣(¯1⍛⌽×1∘⌽)
 
10:07 AM
awesome! i can see why this alternative solution is not preferred, although it removes the duplication of the code. what irks me most with that solution is the repetition of the ones again, but so be it.

is this flipover combinator present in any of the other array languages, like J or BQN? does it have a combinatory logic equivalent? i dont know much combinatory logic, but i find it intriguing. do you think apl should maybe implement such a combinator, or would it not be useful as a primitive due to likely under-utilization?
 
10:17 AM
It is not in any APL
 
@Slimey Well, we can write (1 ¯1)(¯1 1) as (-⍛,⍥⊂⍣2⊢1) if you want to avoid duplication. No, no array language has it. iiuc, the combinatory equivalent would be λabcd.a(bcd)(bdc). It comes up now and then, but is pretty rare, and Dyalog allows writing it as (g⍨f g←…)
I didn't put (g⍨-g←¯1∘⌽⍤⊣×1⌽⊢) in APLcart because I didn't want side-effects.
 
10:29 AM
that is very understandable. thank you for your help!
 
Oh, one more objection against "flipover" is: should it be g⍨f g or g f(g⍨)? Or should both be available‽
 
isn't that first one just g⍛f⍨ ?
 
 
2 hours later…
12:27 PM
@Adám Ha! This is super slick. IIUC, you're doing a fill algorithm on each region, where the fill is a just the index of the largest element in the region. From there it's as simple as counting how many times each of these ids show up and choosing the max.
The ⊢/4 2⍴⍵ really got me. Such a good way to get the horizontal and vertical neighbors.
 
@B.Wilson Thanks, though I didn't think it was so elegant. Silas's ⍸@⊢ is a pretty cool pattern, though.
 
@Adám I kind of see what you mean. The idea, I think, is pretty elegant, but this particular expression doesn't seem to fully manifest that. Hrm...
While I think on this, do you have any thoughts on my particular solution?
My approach leverages a lot more of the symmetry in this particular problem, but I'm not sure whether it's obvious what I'm doing or not.
Let me know if you'd like spoilers ;p
 
12:44 PM
@B.Wilson Yours is the correct approach: direct computation instad of simulation. Code can be cleaned up a bit, though.
 
@Adám If you're willing and have time, merciless pointers would be appreciated!
 
@B.Wilson question: for code golf or production quality?
Welcome to APL Quest 2018-7! Today's quest is Unconditionally Shifty:
> Write an APL expression that given a right argument of a Boolean scalar or vector, and left argument scalar integer of the shift-right amount, returns an appropriately shifted transformation of the right argument.
There are so many approaches to this!
 
1:00 PM
I have two suggestions
{a←-⍺⋄a↓⍺↓a⌽n,⍵,n←⍺/0}
{(⌽⍣(⍺<0))(-|⍺)↓(⍺/0),(⌽⍣(⍺<0))⍵}
The last one I found funny, but perhaps not nice
 
I like th first one very much.
Here's a very different approach: {(⍵↓⍨-⍺)@(⍺↓⍳≢⍵),0×⍵}
 
how nice.
I think many solutiojns are possible
I tried to remove in my second suggestion the double sequence of ⍣
 
{R(-|⍺)↓(⍺/0),(R←⌽⍣(⍺<0))⍵}
 
for example with ⍥ but didn't succeed
 
Have you tried using expand ?
 
1:06 PM
no
 
@Richard You need Under , not Over
Because you want to start by maybe-reversing, then do some work, then finish up by maybe-reversing back.
 
yes exactly
 
So allows insertion of fill elements, omitting elements, and keeping elements. You just have to construct an appropriate left argument.
Unfortunately, I think I found a design flaw in
Wait, no cannot omit elements. nvm
But a combination of and could do it.
inserts |n elements when n is negative, but if n is 0 it inserts 1 fill element 😭
 
to bad..
and how about stencil maybe?
shifting the window of stencil
 
That could work, if not for short arguments :-( We should fix Stencil.
{(0/⍨0⌈⍺),(⍵↓⍨-⍺),(0/⍨0⌊⍺)} is nice an symmetric, but how do I fix it for short data?
There we go, but not so snazzy any more: {(0/⍨0⌈⍺⌊l),(⍵↓⍨-⍺),(0/⍨0⌊⍺⌈-l←≢⍵)}
 
1:17 PM
yes that works
 
OK, completely different approach: {(2⍴⍨≢⍵)⊤⌊(2*-⍺)×2⊥⍵}
 
this looks awesome but don't get it yet
 
We think in arrays (yay!) but in computer science, bit shifts are seen as multiplication or division by powers of 2.
 
ah yes
 
So we convert our binary vector to an integer, do the multiplication/division, and go back to binary (preserving the count of bits).
 
1:23 PM
yes got it
 
That's a fair amount of approaches.
Shall we call it a day?
 
Here's a thing: (↓↑⍨(⊢÷|)⍤⊣×⊢∘≢)⍢⌽
 
Where does it go wrong with stencil? Should the input have at minimum the same length as the window?
 
One less, but yes.
 
@Adám Golf, mostly, but with an eye for grokkability.
 
1:28 PM
@B.Wilson (⊢÷|) Wat‽
Ah, converts 0 to 1
 
:)
 
@B.Wilson Nice. Can be run today as (⌽↓↑⍨(⊢÷|)⍤⊣×⊢∘≢)∘⌽
Anyway, see you next week for 2018-8: Unconditionally SHifty.
 
((-⊣)↓⊣↓(-⊣)⌽n,⊢,n←(|⊣)⍴0⍨)
my bad effort to make it tacit
Next week, thanks!
 
APL days are always good days :D
 
1:53 PM
@Adám That looks like it could use some help from under...
 
2:37 PM
@SilasPoulson {(⌊(2*-⍺)∘×)⍢((2⍴⍨≢⍵)∘⊥)⍵} isn't a huge improvement.
 
(⌊(2*-⍺)∘×)⍢((2⍴⍨≢⍵)∘⊥)
 
@essielovett
 
I need more sugar, one second
 
3:06 PM
@Adám ah - thought you could do the multiplication under 2⊥
 
You need to maintain the number of bits.
 
3:22 PM
As a curiosity, I spotted that there was an (extremely minimal; only handles boolean vectors) APL interpreter submitted in 1989 as an entry to IOCCC: ioccc.org/years-spoiler.html (search for APL on the page). The code itself is ioccc.org/1989/robison.c -- 34 lines of C!
 
3:37 PM
@xpqz The encoding of this interpreter is nice to look at :)
 
 
1 hour later…
4:40 PM
unfortunately, no longer supports by modern C preprocessors.
 
4:52 PM
It's written in a minimal flavour of C called C--
 
5:05 PM
0
Q: (APL) About the power and circle functions

d dWhy does *○0j1 outputs -1 but *(○0j1) doesn’t? (¯1j1e¯16) What is the difference between them? Expected *(○0j1) to output the same thing as *○0j1

 
That's because Dyalog APL has idiom recognition and realises you've typed e^i×pi and so gives you the expect result rather than calculating mathematically *○0j1
 
 
6 hours later…
10:43 PM
0
Q: Why does v[1+(0×(⍴v))] produce a rank error and not the first item in a 2d array?

trisimixFirst, I assign v as: v ← ⍳(4 9) v ┌───┬───┬───┬───┬───┬───┬───┬───┬───┐ │0 0│0 1│0 2│0 3│0 4│0 5│0 6│0 7│0 8│ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │1 0│1 1│1 2│1 3│1 4│1 5│1 6│1 7│1 8│ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │2 0│2 1│2 2│2 3│2 4│2 5│2 6│2 7│2 8│ ├───┼───┼───┼───┼───┼───┼───┼───┼...

 

« first day (2228 days earlier)      last day (413 days later) »