# How to check if all the members of list lies in specific range

I have a list the form:

myList = {{0.12}, {0.12}, {0.12}, {0.12}, {0.14}, {0.12}, {0.14}, {0.12}, \
{0.14}, {0.12}, {0.12}, {0.12}, {0.12}, {0.12}, {0.14}, {0.12}, \
{0.14}, {0.12}, {0.14}, {0.12}, {0.12}, {0.14}, {0.12}}

How can I check if all its elements are in range .10= min && #[[-1]] <= max ) &@Sort[Flatten@list]", "(Min[Flatten@rlst] >= min && Max[Flatten@list] <= max )"}; rlst = List /@ RandomInteger[100, 1000000]; {min,max}={0,100}; Grid[Transpose[{functions,{f[rlst, min, max] // AbsoluteTiming , AllTrue[min<=#[[1]]<=max&]@rlst// AbsoluteTiming, AllTrue[min<=#<=max&]@Flatten[rlst]// AbsoluteTiming, AllTrue[Flatten@rlst, min<= # <=max &]// AbsoluteTiming, VectorQ[rlst, min <= First@# <= max &] // AbsoluteTiming, And @@ Flatten@IntervalMemberQ[Interval[{min,max}], rlst]// AbsoluteTiming, And @@ Flatten@Function[x, min <= x <=max, Listable]@rlst// AbsoluteTiming, And @@ MatchQ[x_ /; min <= x <=max] @@@rlst // AbsoluteTiming, And @@ Thread[min<= Flatten@rlst <=max]// AbsoluteTiming, (#[[1]] >= min && #[[-1]] <= max ) &@Sort[Flatten@rlst]//AbsoluteTiming, (Min[Flatten@rlst] >= min && Max[Flatten@rlst] <= max )//AbsoluteTiming}}], Dividers->All]

{min,max}={0,100}

{min, max} = {0, 99}

{min, max} = {20, 70}

one more: (#[[1]] >= min && #[[-1]] <= max ) &@Sort[Flatten@rlst] or even (Min[Flatten@rlst] >= min && Max[Flatten@rlst] <= max ) .. – george2079 Apr 16 '15 at 18:54      @george2079, I will add the two functions you suggest to the timing experiment -- it may take a day or so (i am using the free programming cloud version and i might have exceeded my daily quota today). Re Through , it is checking the {Min,Max} of Sequence[list, min, max] (not that of list; note the ##) against {min,max}. – kglr Apr 16 '15 at 19:11      yea, I just figured that out, slick. – george2079 Apr 16 '15 at 19:13 A few alternatives VectorQ[myList, 0.1 < First@# < 0.15 &] (* True *) And @@ Flatten@IntervalMemberQ[Interval[{0.1, 0.15}], myList] (* True *) And @@ Flatten@Function[x, 0.10 < x < 0.15, Listable]@myList (* True *) And @@ MatchQ[x_ /; 0.1 < x < 0.15] @@@ myList (* True *)      Personally I like And @@ Thread[10 < myList < 15] – 2012rcampion Apr 16 '15 at 16:27      @2012rcampion Nice, for the OP's data you need Flatten as well And @@ Thread[0.1 < Flatten@myList < 0.15] but it's still short and concise. – C. E. Apr 16 '15 at 16:37 Just for variety: in[lst_, a_, b_] := Min[Sign[(# - a) (b - #)] & /@lst] /. {1 -> True, _ ->
False}

so,

in[Flatten@myList, 0.1, 0.15]

yields True

and in[Flatten@myList, 0.02, 0.1] yields False.

Small modification for closed or half open/closed…