4
$\begingroup$

Say that I have the following table:

{{4.95455, 10.8, 0., 0.02}, {3.43939, 7.46667, 0., 0.03}, {2.68182,5.8, 0., 0.04}, 
{2.22727, 4.8, 0., 0.05},{0.3,08,0.1,0.2},{0.5,1,0.2,0.4},{0.564555, -10.3617, 0.99, 0.94}}

Now I want to remove every row in which: a) the first two elements of each row are above 1, and b) the second element of each row is lower than the first element of each row. I tried to search for a solution but the ones that I find are always about lists and/or removing elements that match particular values (and not conditions). Following these conditions, I would get:

{{0.3,08,0.1,0.2},{0.5,1,0.2,0.4}}
$\endgroup$

1 Answer 1

8
$\begingroup$
Select[Min[#[[;; 2]]] <= 1 && #[[2]] >= #[[1]] &]@list
 {{0.3, 8, 0.1, 0.2}, {0.5, 1, 0.2, 0.4}}

Also:

Select[#[[1]] <= Min[1, #[[2]]] &] @ list
{{0.3, 8, 0.1, 0.2}, {0.5, 1, 0.2, 0.4}}
Cases[{a_, b_, ___} /; a <= Min[1, b]] @ list
{{0.3, 8, 0.1, 0.2}, {0.5, 1, 0.2, 0.4}}
DeleteCases[{a_, b_, __} /; Min[{a, b}] > 1 || b < a]@list
 {{0.3, 8, 0.1, 0.2}, {0.5, 1, 0.2, 0.4}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.