# How to check if all the members of a list lies in specific ranges based on another list?

There are two lists as follows:

lista = {i, j, k};
listb = {{1, 2}, {3, 4}, {5, 6}};


If i in {1, 2} (namely, $$1 \leq i \leq 2$$, where 1 and 2 come from the first item of listb), j in {3, 4}, and k in {5, 6}, it will give True. If only one condition is not met, it will give False. How to make it come true? It's best to achieve the function in one line. Thanks.

ClearAll[f0]
f0 = Apply[And] @* MapThread[Between] @* List;

f0[lista, listb]

1 <= i && i <= 2 && 3 <= j && j <= 4 && 5 <= k && k <= 6

f0[ {1, 3, 5}, listb]

True

f0[ {1, 3, 7}, listb]

False


Also

ClearAll[f1, f2, f3, f4, f5, f6]

f1 = And @@ Between @@@ Transpose[{##}] &;

f2 = And @@ MapThread[Between] @ {##} &;

f3 = And @@ LessEqual @@@ MapThread[Riffle] @ {#2, #} &;

f4 = And @@ MapThread[#2 @ # &]@ {#, Between /@ #2}&;

f5 = And @@ MapThread[Apply[LessEqual] @* Riffle] @ {#2, #} &;

f6 = And @@ MapThread[IntervalMemberQ] @ {Interval /@ #2, #} &;

• In fact, the lista is very large, lista = {{i1, j1, k1},{i2, j2, k2},{i3, j3, k3}.......{in, jn, kn}}, I want to take listb as a filter to sieve the unwanted data out of the lista. For simplification, I only take a item from lista. Your solution is so perfect that it surprises me，leaving endless aftertaste.Thanks. – likehust Apr 13 at 7:55
i = 2; j = 3; k = 4;
lista = {i, j, k}
listb = {{1, 2}, {3, 4}, {5, 6}} Or if you want <=i<= then

MapThread[If[First@#1 <= #2 <= Last@#1, True, False] &, {listb, lista}] ClearAll[i, j, k];
i = 2; j = 9; k = 4;
lista = {i, j, k}
listb = {{1, 7}, {3, 11}, {5, 6}}

MapThread[If[First@#1 <= #2 <= Last@#1, True, False] &, {listb, lista}] • Thanks for your attention – likehust Apr 14 at 1:12