Mathematica Asked on January 27, 2021
Given a 2d array such as x={{1,2},{2,3},{3,4},{4,5},{5,6}}
how would I extract all pairs where the first value is between 2 and 4 such that xpart={{2,3},{3,4},{4,5}}
? I need to do this for a very large data set based on different x value constraints, 2 and 4 are just simplified expression.
x = {{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}}
x // Select[Between[First@#, {2, 4}] &]
(* {{2, 3}, {3, 4}, {4, 5}} *)
Correct answer by Rohit Namjoshi on January 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP