Replies: 1 comment
-
This is intentional. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Each normally applies a function to every element of an array, basically forcing its function to be pervasive, but it doesn't penetrate boxes and as a consequence behaves exactly the same as rows on an array of boxes.
My main question is this: why should these pairs of lines not produce the same output? In other words, why is Each not pervading these boxes?
Right now my best guess is that boxes aren't penetrated to maintain similarity to other older array languages, but if that's intended it certainly wasn't reflected in each's nor box's documentation.
If each did pervade boxes properly, boxes could be used to create jagged arrays without needing to predict box depth ahead of time to use inventory. For example, the previous snippet's intended output (two 4*2 arrays, one with a boxed layer and one unboxed, with 1 in each index) could be produced with
⍚∵(1◌).
, but immediately produces the incorrect output similar to {[1 1] [1] [1 1] [1 1]} when fed an array that has nested boxes like{1_2 {3_4} 5_6 7_8}
.For a better example, say you have a box
{1 2 3 {4 5 6} 7 [8 9]}
and you want to turn each element inside it into pairs of [0, n] where n is whatever element you're currently pairing. The intended output looks something like a little bit like, oh I don't know,{[0 1] [0 2] {[0 3] [0 4] [0 5]} [0 6] [0 7] [0 8]}
. Initially, you might try∵(⊟0)
to couple a0
on with every element inside the box, only to see that the pair[0 {4 5 6}]
has snuck past the ever watchful Each, making it no better than its cousin Rows with its≡(⊟0)
. Eventually this turns you to an hour of research on old array languages and boxing traditions, and making your hair about as jagged as the arrays you're trying to use. Why?Beta Was this translation helpful? Give feedback.
All reactions