@ngn it wasn't for golfing, but .. why not? I was picking up on people here saying "each" is more imperative and less array focused, and challenging myself to rewrite it
using -2 rank-0 take, I see what it's doing; I really need to study rank and shape, I'm getting stuck there a lot
what on earth is it that Rho returns? `n←1 2 3 4 5` is a vector. `⍴n` shape 5 5
the 2 5 reshape works 2(5)⍴n 1 2 3 4 5 1 2 3 4 5
the 2(shape)reshape doesn't 2(⍴n)⍴n DOMAIN ERROR
so it must return a nested vector or something? tally of rho n, shape of rho n, depth of rho n, all 1
ok forget all that, I've just thought to ask what the shape of a scalar is, and they don't have any
@TessellatingHeckler Yeah, NARS's names and symbol choices (they stem from APL2s) are confusing, imho.
@TessellatingHeckler It encloses the entire array, then makes it into a vector of length one, then trades the outermost level of depth (i.e. the one-element vector of something) for increased outer rank, i.e. a leading axis of length 1.
@Adám comma is monadic ravel in this case, which I would have guessed to do nothing on a box, but apparently does something subtle. Trying things, I see the shape of a box is Zilde, so it's a scalar. Ravel seems to unroll all dimensions into a vector, but not change nesting, compared to monadic enlist which seems to completely flatten
@Adám "trades the outermost level of depth for increased outer rank" - I can't quite follow; is that a description of what mix does generally, or what mix is being used to do in this situation?
@TessellatingHeckler Monadic , ravels the elements into a vector, but any nested elements stay. A scalar (nested or not) becomes a 1-element vector. ⍬ is simply an empty numeric vector, i.e. ⍬≡0⍴0
@TessellatingHeckler What it does generally (and here, of course).
It is maybe easier to understand what ↑A does by looking at what ↓A does:
@TessellatingHeckler what helped me out of that problem was a function that showed the shapes trough all the depths. e.g. ⊂1 2⍴⊂⍳3 → [|1 2|3]. examples with it
visually what ↑ is it removes the first |, and ↓ inserts a | before the last number in the first group
@TessellatingHeckler @dzaima There's also displayr from dfns which shows dimension lengths along the top and left sides, and depth in the lower right corner:
The outermost box is a scalar (no dimension lengths in top left corner) of depth 3, containing a 1-row (left border 1) 2-column (top border 2) matrix of depth 2 (bottom left 2) which has two identical elements, both being a 1-by-1-by-2 numeric (~) arrays of the numbers 1 2.
@dzaima Fun exercise: Function that, given an array, gives a complete English description of it. E.g. ⊂1 2⍴⊂1 1 2⍴⍳2 gives Scalar containing a 1-row 2-column matrix containing [a 1-layer 1-row 2-column array containing the numbers 1 and 2] and [a 1-layer 1-row 2-column array containing the numbers 1 and 2].
@dzaima Maybe. I find displayr very clear: you see depth decrease from 3 to 2 to 1 (—) while additional axes (of length 2) are appearing.
@Adám the shapes 1 2 nor 1 1 2 in your example are displayed in a straight line, and imo ...||... is a way clearer way to show a scalar than an empty border
@Adám different uses may require different representations. it may be useful to make the function error on irregular data but that'd make 1 2⍴⊂3 4⍴⊂'foo bar' 'baz' error even though it'd be helpful to at least see [1 2|3 4|3. but the displayr output of that is just useless for me
also big tables - if i have a 10000 row table, I definitely don't want to see the data white trying to figure out what mix of ↑ and ↓ arrows do i need to do before a ⍉
Why exactly does this test case fail: Try it online!. I'm assuming it's a precision issue but I don't see exactly how it hapening. Context is this problem
downvoted bc it's a slight variation of the same problem with 3 elms. i think it's different enough to be new though, since it requires a different approach.