« first day (1570 days earlier)      last day (1084 days later) » 

3:21 AM
⍝ I have a vector v
v ← 1 2 3
⍝ I have a matrix 2, 3 matrix
m ← 2 3 ⍴?⍨10
m
9 4 6
3 8 7
⍝ how to merge a vector and matrix to form a 3 3 matrix?
mat ← 3 3 ⍴ 1 2 3 9 4 6 3 8 7
mat
1 2 3
9 4 6
3 8 7
merge a vector and 2, 3 matrix to form 3 3 matrix?
 
3:41 AM
@elliptic00 1 2 3⍪2 3⍴?⍨10
 
4:11 AM
I mean I'm given a vector and a matrix, I'm looking for something like merge(vector, matrix) => 3, 3 matrix
I think one way to do is to flatten the matrix to a vector and concatenate two vector and take rank 3 3 to recreate the 3 3 matrix.. is there a way to without any flattening?
 
5:11 AM
@elliptic00 That is exactly what the expression I gave you does. You simply use the primitive function "laminate" which is represented by the symbol "comma-bar"
 
 
1 hour later…
6:25 AM
@PaulMansour That's actually "concatenate [along the] first [axis]". Laminate adds new axes, and is spelled ,[ax] or ⍪[ax]
 
Thanks, it works, I just did not realize the symbol is "comma-bar", I though ","
it is hard to see the different "," and "comma-bar" from the screen :)
The next obvious question how to merge a column vector with a matrix?
It seems the "comma-bar" only for row vector?
I mean If you don't want to transpose them and transpose them back,
 
 
1 hour later…
7:40 AM
@elliptic00 , comma would just that
m←2 3⍴1 2 3 4 5 6
c←⍪1 2
    m,c
6 1 7 1
3 4 2 2
I think there're some old books such as APL An Interactive Approach covers these array basics
 
RGS
8:04 AM
@elliptic00 you might also want to take a look at mastering.dyalog.com/Some-Primitive-Functions.html#concatenate
 
 
2 hours later…
10:30 AM
youtube.com/watch?v=6NvNtYChIo8 this'll be interesting
 
can't wait for when it premieres at 2AM
 
haha rip
it's at 10 pm for me which is reasonable
 
10:56 AM
It premieres at 4 am for me
 
 
2 hours later…
RGS
1:08 PM
@rak1507 Same here, but that doesn't mean I'll be available to watch it live :(
Wait, is that a video that will premiere or is it a stream?
 
 
1 hour later…
RGS
2:14 PM
I can use ⎕ED to open the editor
How can I close it right away?
 
I found the following in APLCart for finding the most frequent major cell: {⍵⌷⍨⊂0~⍨⊢/0,⊢⌸⍵} -- took me a few minutes of staring at it to understand, but that's very clever I thought.
 
@RGS What are you doing?
@xpqz It is to avoid computing the unique cells twice. The obvious approach, using to select from , does that.
 
RGS
@Adám I want to open the editor, close it, and then open it again :P
 
Because?
 
RGS
@Adám I want to fight the issue with Link that ignores my whitespace for the first time I Fix a function
:P
 
2:23 PM
@RGS Just update Link!
 
RGS
Why would I do that when I can just fight the system?
Yeah, heading over to GH would do it, right?
 
Yup, or use 18.1.
 
18.1 is a hero release in my book.
 
By me too. So many quality-of-life improvements.
 
Current QoL favourite: ]repr
 
2:27 PM
@xpqz Do you have the newest version that handles functions too?
 
How do you mean?
Tied first place: ]APLCart :)
 
@xpqz Like:
      avg←{
       +⌿⍵
       }÷1⌈≢
      ]repr avg -f=apl
 avg←{
     +⌿⍵
 }÷(1⌈≢)
 
      avg←{+⌿⍵}÷1⌈≢
      ]repr avg -f=apl
┌→───────────────────────────────────────┐
↓* Command Execution Failed: SYNTAX ERROR│
└────────────────────────────────────────┘
Looks like a no.
 
@xpqz That even works without -f=apl:
      avg←{+⌿⍵}÷1⌈≢
      ]repr avg
 avg←{+⌿⍵}÷(1⌈≢)
 
RGS
@Adám It looks like the bug only happens if I open a blank editor. If I open the editor but provide the lines '∇ fnName' '∇' to it, it will always respect my whitespace :') So I didn't have to open the editor twice nor update link :P
 
2:36 PM
@Adám speaking of {⍵⌷⍨⊂0~⍨⊢/0,⊢⌸⍵}, why is the 0, there? For the examples I've tried it seems to work without.
 
RGS
@xpqz Did you try an empty argument?
 
Is this a leading question :)
 
RGS
(I assumed the 0 took care of some empty edge-cases, hence the Q)
 
DOMAIN ERROR
 
RGS
@xpqz ?
 
2:37 PM
You're right, basically.
Without the 0, it DOMAIN ERRORs on empties.
 
RGS
I thought your DOMAIN ERROR was APL erroring when you tried the whole dfn on empty args
I also had a quick go at it right now and it does seem to me that the 0 is taking care of empty things.
 
Yes, so it seems.
 
Otherwise you'll get ∞
 
RGS
Why do I get
      {⍵⌷⍨⊂0~⍨⊢/0,⊢⌸⍵}1 2 3
1 2 3
Aren't the major cells of 1 2 3 the scalars?
 
@RGS not sure, I think it's a stream
 
RGS
2:42 PM
Also interesting to note that, somehow, the code acts in a funky way if ⎕IO←0 and the input arg is a vector with only unique scalars
      ⎕IO ← 0 ⋄ {⍵⌷⍨⊂0~⍨⊢/0,⊢⌸⍵}1 2 3
2 3
 
@RGS it returns all distinct elements with the highest frequency
@RGS APLcart is ⎕IO←1-only
 
RGS
@dzaima yeah but I find it funny that it works well for all other cases
At the expense of two extra bytes the function could be ⎕IO-independent
      ⎕IO ← 0 ⋄ {⍵⌷⍨⊂¯1~⍨⊢/¯1,⊢⌸⍵}1 2 3
1 2 3
 
3:07 PM
@RGS that fails for pretty much everything else (e.g. 1 1 2)
 
RGS
@dzaima wait really?
 
the idea is that it relies on the implicit in padding with 0s at the end
 
RGS
What have I done :P
Ok, I should have said "At the expense of two extra bytes, we can screw up the function", but that's not an impressive feat...
@dzaima thanks for the explanation
Oh wow so I only fully understood what the dfn does now
it is really clever!
 
@RGS yes, that's what I thought. No sorting.
 
RGS
@xpqz in the back of my mind I knew ⌸ was collecting the indices where each major cell appears and I thought we were looking for the major cells where those collections of indices were larger... but the way we determine the collections which are larger is amazing :D
 
3:19 PM
@xpqz unfortunately, it comes at the cost of being worst-case O(n^2)
 
RGS
Hats off to Adám or whoever wrote this wonder.
 
@dzaima why is it quadratic?
 
RGS
@xpqz worst case is when all major cells are different and because there was no sorting, major cell i is compared with all the i-1 major cells that precede it
Over a vector of size n, this gives 2÷⍨n×n-1 comparisons, which is quadratic.
(I might be off by one)
 
@xpqz it needs to build a matrix with as many rows as unique elements, and as many columns as the count of the most frequent element
@RGS all distinct is still O(nlogn)
 
RGS
@dzaima is there implicit sorting, then?
 
3:24 PM
@dzaima (e.g. {⍵⌷⍨⊂0~⍨⊢/0,⊢⌸⍵} (⍳,⍴∘1)20000 WS FULLs on the default 256MB heap)
 
So what is the fastest possible way of doing this?
 
@RGS does whatever it needs to to be fast
 
(with key)
 
RGS
@dzaima but the shape of that matrix is such that +/⍴matrix≤≢input_vector, right?
Or what am I missing.
(i.e. the number of rows + the number of columns is ≤ the length of the input vector)
 
@RGS you need ×/⍴ not +/⍴ to know how large a matrix is
 
RGS
3:27 PM
I know, I was not counting the number of elements inside the matrix
I was stating a constraint on its shape
 
@dzaima APLCart also has this:
((⊣/⊢⍤/⍨∘(⌈/=⊢)⊢/){⍺(≢⍵)}⌸)Y
Whilst I haven't had a chance to fully decode that, it looks as if it should not be quadratic.
as it counts the occurrences and finds the max
 
@RGS more like +/⍴matrix≤1+≢input_vector probably. But that constraint doesn't constrain it much
@xpqz yeah, that should be better
 
RGS
@dzaima Right, off by one.
Ok, so if the sum of the rows and columns is constrained, then the worst-case (as far as memory goes) should occur when all elements are unique, except one of them that occurs in half of the vector, as that should give a matrix with size approximately 4÷⍨n*2
(And that's because when you want to maximise the product a×b with a+b capped at S, you pick a←b←S÷2, cf. mathspp.com/blog/twitter-proofs/maximising-product-fixed-sum)
 
@RGS right. that's exactly what my example does
 
RGS
@dzaima Yeah, it all makes sense now
You just have to give time to the commoners to catch up
 
3:34 PM
(i didn't intentionally make my example to be maximally bad, but a non-optimally bad example would be harder to come up with)
 
How is it that I downloaded the Dyalog IDE all of 7 days ago and it gave me 18.0
Mostly rhetorical, just means I get to change versions
 
because 18.1 isn't released yet
 
... Oh that'll do it
I thought I missed a release
 

« first day (1570 days earlier)      last day (1084 days later) »