Given a list of numbers in Mathematica, how would I extract from that list the total number of numbers between numbers a and b that I specify?
Given a list of numbers in Mathematica, how would I extract from that list
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The most direct way is simply:
There are however much faster ways for most data, this one thanks to Carl Woll:
Carl Woll’s method is particularly fast, but as yoda pointed out, it fails if your list contains zeros, and your range also straddles zero. Here is another method from Kevin J. McCann that handles this case, and is still very fast:
As a pure function [data, a, b]: