An easy new way (since Mathematica 10.2) to remove some part from a list or expression is to replace that part with Nothing
For example you can do
list = {{1, 0.001}, {10^(-7), 0.001}, {0.01, 0.00005}, {10^(-11),
10^(-4)}};
list /. {a_ /; a <= 10^-6, _} -> Nothing
to get:
{{1, 0.001}, {0.01, 0.00005}}
About the syntax:
/.
is ReplaceAll
- ...
->
... is Rule
{a_ /; a <= 10^-6, _}
is a pattern with a Condition
; you can read it "any pair with some first element/expression (say a
) such that a<=10^-6
and any second element (_ is Blank
, any expression)"
The good (or, sometimes, maybe the bad) about this method is that easily translates to the "list of list (of list of list...) of pair". You don't need to change anything:
{list, list, list} /. {a_ /; a <= 10^(-6), _} -> Nothing
{{{1, 0.001}, {0.01, 0.00005}}, {{1, 0.001}, {0.01,
0.00005}}, {{1, 0.001}, {0.01, 0.00005}}}
This method it's just a variant of the "fun" approach of @march, but with an easy-to-understand (?) syntax, available since v10.2. Under a previous you still need to use an equivalent approach:
... /. {a_ /; a <= 10^(-6), _} -> Sequence[]
... /. {a_ /; a <= 10^(-6), _} -> (##&[]) (as of @march comment)
Using Nothing
, Sequence[]
, or (##&[])
and :>
or ->
is not always the same, but, for this sample, it is.
I also add another way:
Pick[list, UnitStep[list[[All, 1]] - 10^-6], 1]
{{1, 0.001}, {0.01, 0.00005}}
not useful in the list of list of pair scenario and not exactly equivalent to the previous, but can have some other advantage:
list2 = Flatten[Table[list, {10000}], 1];
Pick[list2, UnitStep[list2[[All, 1]] - 10^-6], 1] //
RepeatedTiming // First
list2 /. {a_ /; a <= 10^-6, _} -> Nothing // RepeatedTiming // First
0.0338
0.0580
DeleteCases[list, {a_, _} /; a <= 10^(-6)]
$\endgroup$Select[list, First@# > 10^(-6) &]
$\endgroup$GroupBy[list, First@# > 10^(-6) &][True]
$\endgroup$list /. {a_ /; a <= 10^(-6), _} :> (## &[])
$\endgroup$