« first day (2119 days earlier)      last day (542 days later) » 

1:43 AM
@AidenChow 3's and 2's
(f g h) if all 3 are functions, is 3 functions in a row (parenthesized). We call that a fork, a fork is just a function that composes g with the results of h and f. Or in "normal language terms" g(f(x), h(x)) for the monadic case
for the dyadic case (f g h) is the same, but with 2 arguments g(f(x,y) , h(x,y))
or in APL notation monadic is (f ⍵) g (h ⍵) for monadic
for dyadic (⍺ f ⍵) g (⍺ h ⍵)
 
3s with an optional 2 at the end, the rules might be clearer as

1. 3 functions in a row is a fork (or A f g), which is itself a function
2. Go to 1 until there are <2 left to the left of the rightmost identified fork
3. If there is a function 'left over', it is an atop
 
but it isn't 3 with an optional 2
its just 2
because (f (g h i)) , g h i is a fork, a fork is just a function so its actually just (f someFunction)
 
well, sure, but the '2s' is my problem, there isn't more than 1 atop in a train
(anyway pedantry)
 
That's why I ordered it 3s and 2s, not 2s and 3s. 3s first, which collapse to 2s if there's an even number of functions in the train
 
(and in Adám's answers, the first was a 3 train and the 2nd was just a dfn)
 
1:49 AM
@AidenChow the important thing to note, trains are not a new programming abstraction. It is "just" function composition. But it is IMPLICIT function composition
⍤⍥∘⍨ are all EXPLICIT function composition
they have documented rules for how they compose their function operands
so if you're struggling with the explicit function composition, you may want to learn about function composition in general (not assuming here, just I don't know your level of CS theory)
although I don't remember what jot underbar is @rak1507
 
thanks
 
2:18 AM
man thats confusing
 
 
4 hours later…
5:52 AM
@AidenChow The first one is just a golfed version of yours, breaking out into f g h form where f←⊂ and h←⍳∘≢ so we have (⊂⍵) g¨ (⍳≢⍵) which pairs up the entire ⍵` with each element from ⍳≢ and the rest is like before.
{/∘⍵¨i=⊂|⍵-i←⍳≢⍵} creates a vector of vectors, Boolean mask for where the distance is 0,1,2,…,n−1. Then we filter using each mask; is bound () as constant right argument to filter (/) after which that derived function is applied to each (¨) mask.
 
CMC (inspired by conversation in APL farm) shortest code to tessellate n dimensional (up to n=7) array ⍵ into chunks of size ⍺ (guaranteed that it fits evenly, ie ∧/0=⍺|⍴⍵)
{⊂[2×⍳k](,s,⍪r)⍴⍵↑⍨r×s←⌈R÷r←1+(-k←≢R←⍴⍵)↑⍺-1} on aplcart is the baseline
(this really should be trivial with ⌺ but it isn't :( )
 
6:13 AM
@rak1507 {(×⍴⍵)↓⊂⍤⊢⌺(2(≢⍴⍵)⍴⍺)⊢⍵↑⍨-(⌊1+⍺÷2)+⍴⍵}
 
definitely not trivial
 
Nope.
 
and pretty long
 
Yes, this should be an option in
Just add a 3rd row in the right operand specifying what to do at the edges.
 
wow only just realised 99% of the aplcart code is handling fills
so removing all of that blows my solution out of the water
ok CMC amended: don't use ⊂[] :P
 
 
3 hours later…
9:46 AM
@rak1507 I'm sure we've done this one before here, at least the matrix-case; I have a bunch of different solutions in my notes, although not sure how high-rank-general they are. The inverse is also fun: merge the sub-arrays back to the original state.
 
⊂⍤⊢⌺(2 2⍴3)⍣¯1
Wait, ⊂⍤⊢⌺3 3⍣¯1 would be de-blur, right?
Announcement: Now available:
 
10:10 AM
+1
It's the new RTFM
 
 
8 hours later…
6:01 PM
How do you index a whole matrix into a string?
Like 'hello' and 1 2;4 5 would give an array like 'he';'lo'
 
⋄'hello'[2 2⍴1 2 4 5]
 
@xpqz
he
lo
 
One way
But you (like all of us) probably want "select" (aka "sane") indexing:
      (⊂1 2)(⊂4 5)I'hello'
┌→─┐
↓he│
│lo│
└──┘
where I is:
I←⌷⍨∘⊃⍨⍤0 99
It's a proposal for a future addition to Dyalog.
What do you think, @MortenKromberg?
 
6:31 PM
I already have a matrix, not a flat array
I tried that and it didn't work, but I tried it again and it works. Idk, I must have done something wrong lol
Thanks
 
 
4 hours later…
10:21 PM
@AidenChow Hey don't worry, I took much longer than most to become comfortable with trains. And if you look back in time, you'll find that I was just as confused by trains at the beginning.
Just keep at it, and don't get too frustrated. You'll get there. Keep asking questions when you get stuck
 
10:56 PM
@xpqz He agrees, but it'll have to wait for 20.0.
 

« first day (2119 days earlier)      last day (542 days later) »