« first day (846 days earlier)      last day (1809 days later) » 

5:15 PM
0
Q: How do I find array length in APL?

user9791370How do I get the length of my array in APL? It doesn't seem that this question was answered already- correct me if I'm wrong. Thanks!

 
5:43 PM
@Adám suppose I have a vector of boolean pairs such as (0 0)(1 0)(0 1); is there a way to apply (or some other op/fn) so it would return, for this example, 2 3?
 
@J.Sallé Why 2 3?
 
@Adám Well, the idea is that it would return the same as ⍸(0 1 0)(0 0 1)
 
@J.Sallé A domain error?
 
@Adám >.> stupid me, it's ⍸¨(0 1 0)(0 0 1)
 
⎕←⍸¨↓⍉↑(0 0)(1 0)(0 1)
 
5:49 PM
@Adám
┌─┬─┐
│2│3│
└─┴─┘
 
@J.Sallé ↓⌽↑ is a Dyalog-style idiom, i.e. it is very fast and doesn't waste memory.
 
Ah, nice! That's what I needed!
 
@J.Sallé You may also be interested in:
⎕←⍳∘1¨↓⍉↑(0 0)(1 0)(0 1)
 
@Adám
2 3
 
Alternatives are 1⍳¨⍨↓⍉↑ and 1⍳⍨⍤1⍉↑
 
5:52 PM
Okay, just a second
Ah, I needed a second there
I might need some help actually, my function's rapidly becoming an abomination
Yup, an abomination indeed: {⍵⊃¨⍸¨↓⍉↑↑{(>,<)/≢¨{(0=(⍳⍵)|⍵)/⍳⍵}¨⍵,⍎⌽⍕⍵}¨⍳1e4}
I wanted to get that into Extended to use the infinity symbol instead of 1eX (if that's even possible) since idk how big X should be
That's a solution for this challenge btw
 
ngn
6:14 PM
@J.Sallé divisors: {(0=(⍳⍵)|⍵)/⍳⍵} -> {∪⍵∨⍳⍵}
 
Oh, I knew there was a shorter version of that
 
@J.Sallé Or tacit: ∪∨∘⍳⍨
 
Even better
@Adám is it possible to swap the 1eX for the infinity symbol in extended?
 
@J.Sallé No, that'd require too much memory.
 
Hm, I see
my problem is 1e4 only goes as far as 100odd numbers while 1e5 takes very long to run
 
6:27 PM
@Adám is there an overhead difference between funcall and ⍎'funcall'
 
@Nathan yes. is not "dereference" — a function we've contemplated adding.
 
thanks
 
ngn
@J.Sallé {⍵⊃¨⍸¨↓⍉↑↑{(>,<)/.. -> {⍵⌷⍉1↓⊢⌸{×-/..
 
@ngn oh damn
{⍵⌷⍉1↓⊢⌸{×-/≢¨(∪∨∘⍳)⍨¨⍵,⍎⌽⍕⍵}¨⍳1e4} still takes a while but not nearly as long
Very nice, thanks @ngn
 
ngn
@J.Sallé tacit isn't always shorter
≢¨(∪∨∘⍳)⍨¨ -> {≢∪⍵∨⍳⍵}¨
 
6:40 PM
@ngn nice, I didn't see that
 
ngn
well, could've been (≢∘∪⊢∨⍳)¨ but dfns are easier :)
 
7:21 PM
@ngn Look ma, no parens: ≢∘∪¨∨∘⍳⍨¨
 
 
1 hour later…
8:47 PM
@Adám are you still on?
 
@Nathan Yup. Laptop troubles made boot to safe mode, so the chat agent didn't auto-start.
 

« first day (846 days earlier)      last day (1809 days later) »