Skip to main content
deleted 105 characters in body
Source Link
eldo
  • 83.1k
  • 6
  • 72
  • 202
list = {{99., 4.}, {-99., 5.}, {-0.4096, 0.15332}, {-0.40955, 0.13269}};

Using Cases withSequenceSplit Between(new in 11.3)

Cases[First a:@ SequenceSplit[list, {b_{a_, _} /; Between[b! Between[a, {-0.496, 0.4089}] :> a] @ list}]

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Using SequenceSplitCases (new in 11.3)

First @Cases[ SequenceSplit[list,a: {{a_b_, _} /; ! Between[aBetween[b, {-0.496, 0.4089}]}] :> a] @ list

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Performance disclaimer: SequenceSplit is currently (V 13.3) very slowslow with long lists. But many WL functions have shown wild swings in performance between releases (both up and down). So, hopefully, it will improve.

list = {{99., 4.}, {-99., 5.}, {-0.4096, 0.15332}, {-0.40955, 0.13269}};

Using Cases with Between

Cases[ a: {b_, _} /; Between[b, {-0.496, 0.4089}] :> a] @ list

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Using SequenceSplit (new in 11.3)

First @ SequenceSplit[list, {{a_, _} /; ! Between[a, {-0.496, 0.4089}]}]

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Performance disclaimer: SequenceSplit is currently (V 13.3) very slow with long lists. But many WL functions have shown wild swings in performance between releases (both up and down). So, hopefully, it will improve.

list = {{99., 4.}, {-99., 5.}, {-0.4096, 0.15332}, {-0.40955, 0.13269}};

Using SequenceSplit (new in 11.3)

First @ SequenceSplit[list, {{a_, _} /; ! Between[a, {-0.496, 0.4089}]}]

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Using Cases

Cases[ a: {b_, _} /; Between[b, {-0.496, 0.4089}] :> a] @ list

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

SequenceSplit is currently (V 13.3) slow with long lists.

Source Link
eldo
  • 83.1k
  • 6
  • 72
  • 202

list = {{99., 4.}, {-99., 5.}, {-0.4096, 0.15332}, {-0.40955, 0.13269}};

Using Cases with Between

Cases[ a: {b_, _} /; Between[b, {-0.496, 0.4089}] :> a] @ list

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Using SequenceSplit (new in 11.3)

First @ SequenceSplit[list, {{a_, _} /; ! Between[a, {-0.496, 0.4089}]}]

{{-0.4096, 0.15332}, {-0.40955, 0.13269}}

Performance disclaimer: SequenceSplit is currently (V 13.3) very slow with long lists. But many WL functions have shown wild swings in performance between releases (both up and down). So, hopefully, it will improve.