I have a nested array for example:
myVals = {{1, 2, 3, 4, 5, 6}, {20, 20, 21, 3, 15, 7}, {2, 3, 35, 106}};
And suppose I want to select in each sub-array, all elements not equal to 3, then:
Select[#, # != 3 &] & /@ myVals
{{1, 2, 4, 5, 6}, {20, 20, 21, 15, 7}, {2, 35, 106}}
seems to work but I think it's awkward as the place holders # actually represent two different items: The first # is a sub-array like {1,2,3,4,5,6}, and the second one represents each item in that sub-array.
Is this a standard way of doing this in a one-line command? I'm running 12.3.
DeleteCases[myVals, 3, 2]
andCases[#, Except[3]] & /@ myVals
? $\endgroup$Select
, trySelect[#, x|-> ! x == 3] & /@ myVals
$\endgroup$DeleteCases
(and inCases
) should be a pattern. That is, you should use something likeDeleteCases[myVals, x_ /; Abs[x] < 0.0001, 2]
. $\endgroup$