« first day (1519 days earlier)      last day (1136 days later) » 

3:28 AM
@Bubbler I'm confused about what it means in J for an array to have only one axis that is 0 length. Does that mean it's just a single scalar in that axis and has the same shape in the others? When I type 0$i.2 3 4 it doesn't give me any data even though the shape is shown as 0 3 4
 
@dukereg If any axis has length 0, the whole array has zero elements. For example, i.2 3 4 has 2*3*4 = 24 elements. 0$i.2 3 4 has shape 0 3 4, so it has 0*3*4 = 0 elements.
But it is still an array that represents zero layers of 3x4 matrices, so you can concatenate 3x4 matrices on top of it (and no other sized matrices).
Still, the dimensions are associated with the array even if it is empty, and such information is necessary to determine the result of primitives.
 
3:49 AM
A question about defns: why does this return 2? {2 ⋄ 1+⍵} 3
Not sure why it skips the last statement
 
@phantomics Dfns return at the first non-assignment
The first non-assignment in {2 ⋄ 1+⍵} is 2, so it is returned and 1+⍵ is not evaluated at all
 
Ok, I see
Thanks
Is it not possible to run code producing side effects in a defn? I suppose most meaningful side effects will involve assigning part of another object, does calling a function that performs assignment somewhere else count as a statement with an assignment?
 
4:14 AM
@phantomics If the side-effecting code returns a value, you can put _← on its left to continue execution inside the dfn. Otherwise, you need to use dfns.do or apply the hack yourself
 
@Bubbler Makes sense
 
 
1 hour later…
5:40 AM
@phantomics Yes, it does, so e.g. you can do {s←0 ⋄ ⌈/{s⊢←0⌈s+⍵ ⋄ ⎕←s}¨⍵}3 ¯1 4 1 5 ¯9 2 6
 
 
6 hours later…
11:28 AM
Regarding the Linux "SuperKey", all the relevant code changes have been made & committed to Dyalog APL source code for v18.0 and 18.1 + RIDE 4.4. I cannot yet predict exactly when the changes will make it as far as a new non-commercial distribution, I'll keep you posted.
 
11:45 AM
How do you measure the amount of time a given expression takes to compute?
 
dfns.cmpx or ]runtime
 
@EliasMårtenson 'cmpx'⎕CY'dfns' ⋄ cmpx'expr' or ]runtime "expr"
 
Thanks
So I was looking at the expression in the first paragraph of this page: aplwiki.com/wiki/Edsger_W._Dijkstra
How do you actually write that in Dyalog?
 
@EliasMårtenson Don't forget APLcart!
 
The version I came up with is kinda not great (and not very fast, which is why I wanted to know how to benchmark)
@Adám Thanks. I did forget about aplcart
 
11:57 AM
I would write it {+/⍵/⍨⍥,⍵=+/↑⍳⍴⍵}
 
@EliasMårtenson {+/+/⍵×⍵=⊃∘.+/⍳¨⍴⍵} might be faster than ^
@EliasMårtenson Wait, are you asking for the closest modern APL equivalent or are you asking for the fastest expression?
23
Q: Dijkstra's Challenge

AdámPresented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on Mechanical Language Structures, Princeton, N.J. The list of conferees is full of famous and soon-to-be f...

 
12:14 PM
@Adám Actually, I'm asking about both.
It started with me trying to understand the expression and getting nowhere. Then I decided to write my own simply based on the requirements and came up with this: {+/(,⍵=+/¨⍳⍴⍵)/,⍵}
Then I timed it, and it's slow.
 
Because it generates a potentially huge array of vectors, then loops over them.
+/(M=(⍳1↑⍴M)∘.+⍳1↓⍴M)/⍥,M is the best literal translation I can come up with, and it should be quite fast.
 
+/¨ -> +/↑
 
But that still goes via a nested array.
 
true
 
(1↑⍴⍵)∘.+⍥⍳(1↓⍴⍵) would be another flat approach, but ⊃∘.+⍥⍳/⍴⍵ should work too even if it has one pointer.
 
12:20 PM
      ]runtime -c '⊃∘.+⍥⍳/⍴M' '+/↑⍳⍴M'

  ⊃∘.+⍥⍳/⍴M → 4.9E¯6 |      0%
  +/↑⍳⍴M    → 7.1E¯4 | +14455% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
oh, you beat me to it!
 
Interesting how Iverson used // to compress a matrix, returning a vector. This fits with the proposals for extension that dzaima and I have.
 
@rak1507 That one is roughly the same speed as mine.
 
@Adám yeah, don't know why that's not valid now
 
@Adám it's, like, such an obvious and useful extension :|
 
@Adám Wait what? Compress matrix?
You mean something like +/+/ ?
 
12:24 PM
No, that's reduce.
And Iverson only reduced once, so the result of // is clearly a vector.
 
@EliasMårtenson dzaima/APL
 
@user965986 Hi สายใหม สีชมพู. If you want to participate here, just email access@apl.chat
@dzaima Though it isn't clear how Iverson would have treated a 2D left argument and 3D right argument. I think the natural thing is to return an argument of rank 1+-⍥(≢⍴)⍨
 
@Adám yeah, that's the full leading axis version or whatever. much less useful though
 
@dzaima How so? Can you come up with a sensible use case for your model?
Also, if my model is implemented, one can easily do ⍥, to get yours, but not vice versa.
 
@Adám well, here is one. this contains another. And I have used it plenty of other times (though admittedly i've pretty much never used actual leading axis stuff besides for scalar primitives sometimes)
and why is your model incompatible with mine?
 
12:34 PM
@dzaima "here is one" ― where?
 
@Adám the whole "// is clearly a vector"?
(by "much less useful" i didn't mean i have any alternate model, just that the full leading axis definition is much less often needed than the equal dimensions case)
 
Oh, right, but our models agree on the equal dimensions case.
 
and since my model doesn't define non-equal dimensions, they're compatible
 
Oh. I didn't realise. I thought yours was ⍥, if left arg had rank≥2
 
no, mine's {⍺≢⍥⍴⍵:error ⋄ ⍺/⍥,⍵}
 
12:39 PM
Hold on, that's only if left arg has rank>1, right?
So your model has an exception, while mine is a generalisation.
 
uh, yeah. dzaima/APL doesn't even implement the vec/highRank case :p
 
Really? You can't filter the rows of a matrix at all?
 
nope
 
Oh wow, that's pretty core stuff in APL, imo.
 
never needed to, and now probably never will
 
12:42 PM
So, in dzaima/APL, how do you find sums of the rows of a matrix where the rows have no 0?
I.e. +/M⌿⍨∧/M≠0
 
@Adám you either store as a row/column vector (i'd estimate either the row or column count would be constant in the vast majority of cases), or get sad and cry in a corner :)
@Adám i'd rather define mine as "the useful subset" of the generalization. how often are you gonna have a 3D+ array and want to filter it by a 2D+ boolean array?
 
 
2 hours later…
2:18 PM
@Adám +/M+.×⍨M∧.≠0
 
2:45 PM
In the Dyalog (pdf) docs for user commands, to load the SAMPLES group, it says to issue the command ` ]Settings cmddir ,[SALT]/study`. Is that verbatim, or is the [SALT] something that should be substituted? It's not clear to me.
 
@xpqz SALT does envvar substitution of words in square brackets, so verbatim.
 
Ok. Should I expect this to work on a Mac?
 
Yes.
 
It doesn't.
Here"
 
@xpqz Oh, it is working, but apparently at least one of those study examples creates a class derived from a built-in WinForms GUI class :-/
 
2:50 PM
:D "working"
 
Can you email support@ asking for the documentation to include that this is Windows-only?
 
Sure.
 
 
3 hours later…
5:44 PM
Is there a way to capture data returned from a ]usercmd into a variable?
Like
a←]cmd arg
which doesn't work, but shows intent
 
@xpqz You can get general info from ]
I should add that to APLcart.
 
Ah, check that out.
 
@xpqz Try erasing $DYALOG/SALT/study/GUI and then try again.
 

« first day (1519 days earlier)      last day (1136 days later) »