-
The elements of a 1d array can easily be filtered with
How can I do the same for a 2d array? Things I've tried that don't work
|
Beta Was this translation helpful? Give feedback.
Answered by
kaikalii
Oct 29, 2023
Replies: 1 comment 1 reply
-
The problem becomes that the filtered rows may end up being different lengths, so you cannot reform the array normally.
Here are some examples of how they would be used here. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
memark
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem becomes that the filtered rows may end up being different lengths, so you cannot reform the array normally.
The three main ways of solving this are
box
,pack
, andfill
.box
ing the result ofkeep
on each row wraps each filtered row in a boxpack
does the same, but only if it is necessaryfill
fills in the lengths of each row so that reforming the array works correctlyHere are some examples of how they would be used here.
Notice the difference between using
box
and usingpack
on arrayB
.