« first day (1996 days earlier)      last day (659 days later) » 

1:46 AM
Occasionally known as “featuritis”.
 
 
1 hour later…
3:13 AM
hi, so I wrote a function but I'm not happy with it... can somebody suggest improvemens? For one it's way too long and for two, I can't help but think there might have been some built in or pattern I'm not familiar with
the function is: idxs ←{,[0 1]↑(1 0 1 0 1 0⊂⊢)¨{⍵,(0 3⊃¨⊂⍵)}¨((0⌷⊢∘⍉)∘.,(0⌷⊢))⍳⍴⍵}
and you use it like this (idxs data) ⊃¨⊂ data
what it does is it takes a table and "unpivots" it
takes data:

┌──┬───┬───┐
│ │c1 │c2 │
├──┼───┼───┤
│r1│v11│v12│
├──┼───┼───┤
│r2│v21│v22│
├──┼───┼───┤
│r3│v31│v32│
└──┴───┴───┘
and turns it into


┌──┬──┬───┐
│ │ │ │
├──┼──┼───┤
│ │c1│c1 │
├──┼──┼───┤
│ │c2│c2 │
├──┼──┼───┤
│r1│ │r1 │
├──┼──┼───┤
│r1│c1│v11│
├──┼──┼───┤
│r1│c2│v12│
├──┼──┼───┤
│r2│ │r2 │
├──┼──┼───┤
│r2│c1│v21│
├──┼──┼───┤
│r2│c2│v22│
├──┼──┼───┤
│r3│ │r3 │
├──┼──┼───┤
│r3│c1│v31│
├──┼──┼───┤
│r3│c2│v32│
└──┴──┴───┘
 
you can only make a whole message a code block (you can edit the message and ctrl+k)
┌──┬───┬───┐
│  │c1 │c2 │
├──┼───┼───┤
│r1│v11│v12│
├──┼───┼───┤
│r2│v21│v22│
├──┼───┼───┤
│r3│v31│v32│
└──┴───┴───┘
↓
┌──┬──┬───┐
│  │  │   │
├──┼──┼───┤
│  │c1│c1 │
├──┼──┼───┤
│  │c2│c2 │
├──┼──┼───┤
│r1│  │r1 │
├──┼──┼───┤
│r1│c1│v11│
├──┼──┼───┤
│r1│c2│v12│
├──┼──┼───┤
│r2│  │r2 │
├──┼──┼───┤
│r2│c1│v21│
├──┼──┼───┤
│r2│c2│v22│
├──┼──┼───┤
│r3│  │r3 │
├──┼──┼───┤
│r3│c1│v31│
├──┼──┼───┤
│r3│c2│v32│
└──┴──┴───┘
I think {↑{a b←⍵ ⋄ (a 0)(0 b)(a b)}¨,⍳⍴⍵} works
 
3:35 AM
faster fancy alternative - {↓1 0 2⍉↑(1 0)(0 1)1×⍤1¨⊂↑,⍳⍴⍵}
2
 
 
1 hour later…
5:04 AM
Nice trick with (1 0)(0 1)1×⍤1 ...
thanks I learned something
 
 
1 hour later…
6:08 AM
@elliptic00 The Julia language is perhaps the closest.
 
 
2 hours later…
8:27 AM
@Chewxy For next time, consider posting on:
 
 
5 hours later…
1:01 PM
{(,⍳⍴⍵)∘.×(1 0)(0 1)(1 1)} seems to work too
{(,⍳⍴⍵)∘.×(1 0)(0 1)1}
 
1:23 PM
It seems to be slightly slower than dzaima's fast solution, but I have no idea why
 
@rabbitgrowth that'll be because some pretty funky low-level things; my guess would be that × on nested arrays goes some generic path that does effectively ¨, not thinking too much about the performance in the case the arrays that's done on are tiny (which they are); whereas and are specifically about manipulating array sizes, so they've got more effort put in to be fast on small arrays. (and ×⍤1 is gonna be very fast because its done on large flat arrays)
 
 
1 hour later…
2:47 PM
Announcement: BAA webinar (open session) in 10 minutes: Zoom 858 532 665 (zoom.us/j/858532665), passcode: ⎕←×/1920 12 17
 
@Adám 391680
 
Announcement: week.golf adds a new programming language each month, by vote. APL, J, and BQN are candidates. You can vote at week.golf/newLanguage.php
 
 
3 hours later…
6:17 PM
@Adám Jelly too
 
Sure, but Jelly isn't really on-topic here.
 
 
3 hours later…
9:00 PM
@Adám I only see Python? Or should I create an account?
 
Yes, there appears to be a bug where you only see Python until you have an account.
 
9:27 PM
ok done. Just 14 votes now? We must be able to do it better. And almost half of these languages I do not take serious (including Basic and Pascal)
 

« first day (1996 days earlier)      last day (659 days later) »