05-28-2010 02:04 PM
Is there a method of searching an array for the first element which is less than a set number? - Like the Search Array function but with comparison instead of equals?
Thanks
Solved! Go to Solution.
05-28-2010 02:19 PM
I don't think there's a direct way.
One simple option: do your comparison first (you can compare an array to a scalar), this will result in a boolean array. Then search for "True" in the boolean array.
05-28-2010 02:24 PM
05-28-2010 05:16 PM
If you have a large dataset, you should be a little careful. Doing the comparison and then searching guarantees that you will operate on every element of the array and will also create a new one. In this case just use a for loop with the conditional terminal set to stop when the condition is met. This way you don't have a new buffer allocation, and you short-circuit the operation when you find the answer. Be sure to check if you reached the end of the array (your loop will stop with a value of False for the last comparison).
All that said, I use the previous suggestion 95% of the time.