« first day (2040 days earlier)      last day (614 days later) » 

12:07 AM
I got a little lost in your corrections but for ⍴ ,/ (1 2) (3 4) you catenate two enclosed lists to get a single enclosed list which amounts to a scalar and hence has no shape. The second example is exactly the same. It's not clear to me what output you want from what input.
 
The use case I have is as follows:
 
Did you want the behavior of 1 2,3 4? I think then the issue might be understanding stranding. I.e. exactly what (1 2) (3 4) means.
 
I have k vectors with shape (1 2) that I need to convert into a vector of shape (1 2*k) for which I can recover the shape using ⍴
Shape is important due to the application I have (physics with tensors)
 
Where are the k arrays of shape (1 2)? Do you have a list of enclosed arrays or an array of shape 1 2,k?
 
I have a list of enclosed arrays, I think
 
12:13 AM
If we stick with two it might be easier to show. Let's do that for now.
 
This does concatenation along the first axis: (1 2⍴2)⍪(1 2⍴3)
Here, they're not enclosed, though.
 
Oh, I think I see what you mean
or not
 
This (⊂1 2⍴2)⍪(⊂1 2⍴3) is different from this ⍪⌿(1 2⍴2) (1 2⍴3) though I'm having difficulty explaining the principle. Hopefully someone else will chime in.
BTW, I'm using ⌿ instead of / but they're essentially the same here. The first is along the first axis and the second is along the last axis, but since these are vectors and thus have only one axis they are the same.
 
12:34 AM
To explain the part I understand, if you have two 1 2 vectors (like (1 2⍴3) and (1 2⍴4)) not enclosed, concatenating along the first axis means joining the second after the first in that direction, so that the dimension of that axis become the sum of that. I.e. this takes a vector of shape (1 2) and another of shape (1 2) and makes one of shape (2 2).
Oh, but you wanted something of shape (1 4), right?? In that case, you want to join along the second axis which in this case is the last axis. So (1 2⍴3),(1 2⍴4).
So what's left to explain is how the enclosing changes this. (⊂1 2⍴3),(⊂1 2⍴4) joins to enclosed arrays (i.e. scalars) to make a vector of two elements, but ,/(1 2⍴3) (1 2⍴4) creates the enclosure of (1 2⍴3),(1 2⍴4). So it looks like there is an implied disclose of the elements of (1 2⍴3) (1 2⍴4). I knew each did that, but hadn't registered that reduce does as well.
Sorry if I've made this more complicated, but I think in the end you want to simply disclose the result of ,/(1 2⍴2)(1 2⍴2). I.e. you want ⊃,/(1 2⍴2) (1 2⍴2).
 
1:20 AM
@doug (⊂1 2⍴2)⍪(⊂1 2⍴3) ←→ ⊃⍪⍥⊂⌿(1 2⍴2) (1 2⍴3)
say, 1 + 1 2 3 ←→ ⊃+/(1)(1 2 3)
or ⊃⍪⌿(⊂1 2⍴2) (⊂1 2⍴3)
it is not hard to explain that, a f b ←→ ⊃f/a b holds
is important if a b is boxed array
if you interpret literally as the box drawn, you would misunderstand that
 
@LdBeth What I hadn’t grokked is that similar to each reduce unboxes each of the elements of the list it acts on before applying its operand and boxes the result. If the elements of the list and the result is a scalar then this aspect is a noop.
Explaining applying a primitive in terms of reduce on that primitive feels backwards.
 
1:35 AM
again ⍪⌿(1 2⍴2) (1 2⍴3) ←→ ⊂(1 2⍴2)⍪(1 2⍴3)
 
I’m also learning J right now where this implicit unboxing/boxing doesn’t happen and so my radar is a bit off at the moment.
Yes. I explained why above. The stranding produces a list of boxed items.
 
I'm only saying there is such rule that a f b ←→ ⊃f/a b been kept, and all the behavior of APL shown here is consistent which this rule.
so, can you agree on that ⊂(1 2⍴2)⍪(1 2⍴3) and (⊂1 2⍴2)⍪(⊂1 2⍴3) should be different?
 
That’s fair. I hadn’t noticed the requirement to unbox as I mentioned above.
Yes, those are different but that was never at question.
 
for Dyalog APL allow write say (1 3) (2 3), this is the ambiguity raised from notation. Actually ISO APL specification is not compatible with this notation
 
I’m having trouble parsing that. In any event I think my explaination covers strands longer than two.
 
1:43 AM
you mean when you write (1 2⍴2) (1 2⍴3) for shorthands of (⊂1 2⍴2),(⊂1 2⍴3)?
 
Also, stranding isn’t directly relevant. ,/(⊂1 2⍴2),(⊂1 2⍴2)
 
that is ⊂(1 2⍴2),(1 2⍴2)
 
Yes. Unboxing happens regardless of how it got boxed. (Or is a noop in the case if scalars)
 
where is unboxing? I couldn't see any in this example
 
I don’t think anyone is arguing what the output is.
 
1:47 AM
(⊂1 2⍴3),(⊂1 2⍴4) is the same as (1 2⍴3)(1 2⍴4), so I don't know what exactly you have difficulty with
 
You apply reduce to a list of boxed elements and the primitive is applied to the unboxed versions as described above.
At this point I don’t have difficulty. Maybe this is a good place to stop.
 
,/(⊂1 2⍴2),(⊂1 2⍴2) ← by stranding definition → ,/(1 2⍴2)(1 2⍴2) ← by reduce definition for boxed array → ⊂(1 2⍴2),(1 2⍴2) I don't see any unboxing here
The only "strange" thing here is reduce is a little different for boxed array, unlike J
 
I didn’t use the word strange. I’ll leave it here: given a list of boxed elements you could applied the primitive to those elements themselves but that’s not what happens.
 
Thanks for the outstanding discussion above. I was not aware of the subtleties of enclosing in APL. That solved my problem very elegantly.
 
2:03 AM
@doug so, APL2 specification says, LO/A B C ←→ ⊂ A LO B LO C, and the for +/1 2 3 is 6 is because ⊂6 ←→ 6 in APL2 compatible implementations, but in J <6 is not the same as 6.
so, yes in J we would just intuitively say LO/A B C = A LO B LO C without enclose, but APL2 is actually a little anti intuition if you digging into formal specification
 
@SantiagoNuñez-Corrales Fantastic
@LdBeth - But that explicitly explains reduce over a stranded list. As I mentioned above the behavior exists in the absence of stranding and explaining it in relation to stranding seems roundabout. The explanation I give makes no such reference but explains the behavior of both.
 
 
18 hours later…
8:34 PM
@SantiagoNuñez-Corrales You can edit your messages for a couple of minutes by pressing UpArrow.
 

« first day (2040 days earlier)      last day (614 days later) »