How do I use ">" and "<" inside "Cases" Mathematica function?
E.g., I would like the cases which end in something greater than 2 for the following nested list:
lst = { {1, 0, 0}, {1, 1, 1}, {1,1,4} }
I would like to do something like
Cases[lst, {_, _,>2} ]
What it is the correct way to express ">2" above?
The most straightforward fix to your approach is probably
Cases[lst, {_, _, x_ /; x > 2}]
See the documentation for /; or Condition.
Alternatively,
Cases[lst, {_, _, _?(# > 2 &)}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With