« first day (2536 days earlier)      last day (113 days later) » 

6:23 AM
@RubenVerg That looks very pretty.
Is this normal?
      x←1 2 3
      x[1+1]←4
      x
1 4 3
      x←1 2 3
      (x⊃⍨1+1)←4
SYNTAX ERROR
      (x⊃⍨1+1)←4
              ∧
 
6:41 AM
@rabbitgrowth In selective assignment, the rightmost token on the left needs to be the name you're modifying, I believe: (2⊃x)←4 works.
 
7:00 AM
Ah I see. ((1+1)⊃x)←4 does work. Thank you!
I thought it was the + that was causing the problem.
 
 
4 hours later…
11:30 AM
@Adám I am probably late today so here is my suggestion for the Quest.
⊢(/⍨)⊢=⌈\
 
Noted.
 
 
1 hour later…
1:00 PM
Welcome to APL Quest 2023-1! Today's quest is Elimination Sort:
> An "Elimination Sort" is a somewhat farcical sorting algorithm which starts with the leftmost element and keeps subsequent elements that are at least as large as the previous kept element, discarding all other elements.
Write a function that:
• takes a non-empty numeric vector right argument
• returns an "Elimination-sorted" vector of the right argument
@Richard This is about as good as it gets.
Although the explicit version is just as good: {⍵/⍨⍵=⌈\⍵}
I just can't wait for Behind…
Since ⍵=⌈\⍵ is max-scan equal to self, it can be written ⌈\⍛=
And then we have the same pattern again; this ^ replicate self, so it can be written this⍛/
Putting both together, we'll have ⌈\⍛=⍛/ which is as elegant as it can get, imo.
The test framework even allows you to write Ⓞ←{⍺←⍵ ⋄ (⍺⍺ ⍺)⍵⍵ ⍵} ⋄ ⌈\Ⓞ=Ⓞ/⍵
 
I remember considering submitting ⌈\{(⍺⍺ ⍵)⍵⍵ ⍵}≥{(⍺⍺ ⍵)⍵⍵ ⍵}/⍵ but ended up submitting the one without Behind in the end
which would've been better?
@Adám also, why can't I make inline assignment work with this? does it not work with ddops or am I just doing something wrong?
 
1:15 PM
@RubenVerg What fails?
 
⌈\_Before_≥(_Before_←{(⍺⍺ ⍵)⍵⍵ ⍵})/⍵
 
@RubenVerg Without it is better, as the inline operator just obscures matters.
Dyadic operators are lesser-class citizens. You can't return them from an expression.
 
why?
 
No particular reason.
@user22425222 Hi Kristi Grg, if you want to participate here, please email access@apl.chat
 
I had {⍵/⍨⍵≥⌈\⍵} when I should have written {⍵/⍨⍵=⌈\⍵}
I wonder why the hint recommends using
 
1:20 PM
It doesn't really matter, since can never be greater than ⌈\⍵ it'll always use the = part of .
Maybe it makes for a more natural implementation of "at least as large".
 
⌉←⍵
⌈\⍛=⍛/⌉
 
Which reminds me, anyone attempt a pair-wise comparison?
 
What do you mean I can't assign to symbols
Wouldn't you need to consider more than adjacent pairs?
 
Well, you could eliminate anything that is less than its neighbour on the left, then find the fix-point.
{⍵/⍨1,2≤/⍵}⍣≡
Ooh, here's an idea for those that found this too easy: Implement proper general elimination sort, not just for numeric vectors, but for any sortable array.
 
is that not just your pairwise-based code replacing with a TAO comparison (grade match 1 2, or something like that)?
 
1:30 PM
Yup. You can even look up on APLcart.
Well well, I guess that'll be all then. See you next week for 2023-2: Put It In Reverse.
 
I really hope someone came up with crazy solutions to next week's during the contest
it really feels like a problem that can only be approached one way
 
Oh no, there are at least a couple of good approaches.
 
@Adám {⍵[⍸(⍋⍋⍵)=⌈\⍋⍋⍵]}?
Wait, that's just {⍵/⍨(⍋⍋⍵)=⌈\⍋⍋⍵}, of course
 
You'd need but yes, that's very nice. Why not assign ⍋⍋⍵ a name?
Or even {⍵⌿⍨(⊢=⌈\)⍋⍋⍵}
 
Because I suck at naming :)
@Adám Yeah, I like that
 
1:39 PM
⌈\⍛=⍤⍋⍤⍋⍛⌿
 
Lovely.
I'm still a bit bothered by how f⍛g Y is (f Y) g Y but f∘g Y is f g Y instead of Y f (g Y), especially since we're already recommended to use f⍤g Y for f g Y, but oh well.
 
Right, but the problem is with f∘g which should have been {⍺←⍵ ⋄ ⍺ ⍺⍺ ⍵⍵ ⍵}
Of course, that would make for a that doesn't match TMN. and should have been swapped.
 
Adám, when you say "do not use a dfn instead of naming a variable" in abrudz.github.io/style/#df, you mean specifically dfns, and tacit functions are not included, right? As in, {⍵⌿⍨{⍵=⌈\⍵}⍋⍋⍵} is not recommended, but {⍵⌿⍨(⊢=⌈\)⍋⍋⍵} is OK?
 
1:54 PM
Right, that's my intention.
 
Why dfns specifically then?
 
Noisier, and they introduce a whole new function, and thus stack, scope. Tacit functions have no scope.
The dfn really gains you nothing over naming.
 
That's true. Since is just a generic name, I might as well have written {⍵⌿⍨x=⌈\x←⍋⍋⍵}. That's shorter, too.
 
Exactly, but the tacit function avoids a name, and is equally short.
 
I see. Thanks a lot for the explanation.
 
2:28 PM
@Adám This gets nicer the more I think about it. It literally just describes the desired outcome.
 
3:22 PM
@rabbitgrowth because then you could have a variable called rho(⍴) and say shape of rho (⍴⍴) which would be very confusing
 
 
6 hours later…
9:11 PM
0
Q: GNU APL, using ⎕FIO output directly vs assigning it to a variable gives different results, I don't understand

johnnynbI have been "relearning" APL with Dyalog but thought I would give GNU APL a try. I'm having a problem understanding the results of reading a text file via ⎕FIO The text lines output directly from ⎕FIO are different than when the output is assigning to a variable. I'm reading a text file that cont...

 

« first day (2536 days earlier)      last day (113 days later) »