« first day (2207 days earlier)      last day (447 days later) » 

4:51 AM
What's the best way to do 2f/⍵ where f is a dyadic function and is an array, except operate on 'non-overlapping' pairs. I'm curious about both the most idiomatic way, and also the golfiest way.
Eg. you want:
2+/5 2 4 8 9 5 → 7 12 14
Instead of the usual:
2+/5 2 4 8 9 5 → 7 6 12 17 14
 
5:25 AM
@AviFS I'd probably do +/⊢⌺(⍪2 2)
 
@Adám Oh wow, hi. Good early morning!
What's the way to just split into 2-length pieces. Or to reshape into a 2-n matrix. (I did check APLcart.)
I'm surprised at the use of stencil for this.
 
Once we get array notation, we can write the slightly shorter and neater +/⊢⌺[2⋄2]
@AviFS You mean n-2 matrix, no?
That'd be ⊢⌺(⍪2 2)
@AviFS So you found (⊢⍴⍨2,⍨2÷⍨≢) on APLcart?
 
6:04 AM
Three back-to-back Commutes feels a bit much, IMHO. At the very least, something like {(⌈0.5×≢⍵) 2⍴⍵} parses more immediately for my (still APL student) brain.
@Adám Ooh! Higher-ranked array literals possible, too?
 
 
2 hours later…
8:08 AM
@B.Wilson Yes, see apl.wiki/Array_notation
 
 
2 hours later…
10:26 AM
@B.Wilson Hopefully {⍬ 2⍴⍵} someday
@Adám What do you think ⍬ 2⍴⍳15 should give ?
 
That's part of the issue. doesn't contain a value, so it cannot indicate whether to shorten, lengthen, recycle, or error.
Also, (although equivalent to ravel) you'd need (⊂⍬)⍴ rather than (⍬⍴)
 
If I had to choose one it would be lengthen, but I think it'd be a mistake to not consider alternatives thoroughly
 
One alternative is using four different numbers (or letters!).
 
An alternative idea is adding first-axis reshape which has a specification in the left argument similar to BQN
 
Since we can lengthen/recycle with overtake/reshape, I'd be inclined to just error if the element counts don't match. Though since recycles, maybe just defaulting to recycle also "makes sense"?
In the wild, is there a clear winner for the behaviour that is most commonly called for?
 
10:38 AM
@essielovett Recycle gets my vote for least surprising behaviour.
 
Yeah
Lengthen seems the most useful to me
 
@B.Wilson Speaking for myself, I only ever wish for this behaviour when I know it's a perfect fit. I can't remember what k does here.
 
@xpqz heh, I'd say recycle would be the most surprising behavior. I can see how it makes sense as an extension of regular Reshape, but for a ⍬ 2⍴ specifically it'd always result in putting a column 1 element in column 2, which I don't think would be desired like ever, and it only recycles to a max of less than one row too
 
Is it more surprising than 5⍴⍳4 putting the first element last? The recycle behaviour always seemed more puzzling to me full stop, than the padding behaviour of (over)take.
 
you can do 8⍴⍳4 though, which neatly repeats all elements twice; but 5⍴⍳4 is indeed strange. No way to do the former with a ⍬n⍴ though, all you can get is the weird behavior of 5⍴⍳4
 
10:49 AM
Do you think that extending with the prototype is the way to go?
Or a set of magic values to specify the behaviour?
 
I personally think erroring is the sanest default if going for one option; multiple options is also acceptable, but I haven't found myself ever in a situation where I need padding and the prototype/fill element is acceptable
 
11:34 AM
@essielovett How does first-axis reshape enter the picture? Surely, that's incompatible with the existing
@essielovett I think shorten makes the most sense, as then it is easy to append some elements (of your choice, including from the beginning if you want recycle) to achieve a lengthen.
Also, there's precedent for shorting, as ⎕MAP includes this feature (with ¯1 being the special value) and it shortens.
 
 
1 hour later…
1:00 PM
Welcome to APL Quest 2018-4! Today's quest is What’s Your Sign?:
> Write an APL expression that, given a scalar integer year, returns a character vector (string) of the Chinese zodiac sign for that year.
2018	Dog		2012	Dragon
2017	Rooster		2011	Rabbit
2016	Monkey		2010	Tiger
2015	Goat		2009	Ox
2014	Horse		2008	Rat
2013	Snake		2007	Pig
> Note that the year 1 AD (represented as 1) follows the year 1 BC (represented as ¯1) with no intervening “0” year.
 
{sign←'Pig' 'Rat' 'Ox' 'Tiger' 'Rabbit' 'Dragon' 'Snake' 'Horse' 'Goat' 'Monkey' 'Rooster' 'Dog' ⋄ sign[(⍵<0)+1+12|⍵-2007]}
Where the 2007 can be removed by rotating the vector a few postitions
 
You need a disclose.
 
Yes, it was there...
 
But yes, this does it. Btw, you can also remove 12|
 
why? Doesn't that give an index error?
 
1:03 PM
Oh, sorry, of course it does.
I made this mistake because my own solution just rotates the array and picks the first.
⊃('MonkeyRoosterDogPigRatOxTigerRabbitDragonSnakeHorseGoat'(∊⊂⊣)⎕A)⌽⍨⊢+0∘>
 
btw my solution wasn't accepted by try apl.
@Adám niice one!
 
@Richard Passes for me (with added )
You could also just write sign⊃⍨ or use the literal instead of a variable.
 
@Adám yes it does
 
With 20.0's Behind, we can write ⊃0∘>⍛+⌽'MonkeyRoosterDogPigRatOxTigerRabbitDragonSnakeHorseGoat'(∊⊂⊣)⎕A⍨
 
Ah, and the rotate solution automatically coorects for the year '0' because it doesn't do a rotation then
 
1:10 PM
No, I still need the 0∘>⍛+
In fact, we can even do the split-on-uppercase with Behind: ∊∘⎕A ⍛⊂'MonkeyRoosterDogPigRatOxTigerRabbitDragonSnakeHorseGoat'
 
ok, now I see.
nothing special about this problem anymore I think.
 
Nah, it seemed complex at first, but is not that bad.
 
the next problems for 2018 are also a little bit less inspiring. But I will make them tacit as an exercise
Probably is quite a task to make those problems.
 
Well, maybe you're graduating from this level?
 
Maybe, lets hope so :)
 
1:18 PM
@Richard It is indeed. We start even before the previous round finishes.
 
You don't want them to be to difficult or to easy. And I see you also try to use a theme or some kind of continuing story
 
Yes, and sometimes tie-ins with phase 2.
 
I also see them evolve during the years
 
I'm always pushing for them to become easier.
 
BUt at the same time you don't want the gap between phase 1 and the beginning phase 2 to be too large, as that might disencourage people
And partly it is an programming exercise, but also partly thinking about logical solutions.
 
1:23 PM
hence me wanting phase 2 easier too.
 
That's at least why I do like them
Compliments to the team
And see you next week
 
 
2 hours later…
3:40 PM
Super late to the party, but this is my quickly-hack-it-out solution:
`(⊃'Monkey' 'Rooster' 'Dog' 'Pig' 'Rat' 'Ox' 'Tiger' 'Rabbit' 'Dragon' 'Snake' 'Horse' 'Goat'⌷⍨1+12|⊢+<∘0)`
@Adám Hahahaha! Leveraging the capitals and rotating the the list of values instead of moduloing the index. Beautiful.
 
 
3 hours later…
7:03 PM
suggestion: make dyalog install apl keyboards only for the primary language by default
its annoying that i keep having to remove the russian apl layout from the computers i install apl on
 

« first day (2207 days earlier)      last day (447 days later) »