Jump to content

Using the while function to search for values greater than X


This topic is 891 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi guys... is this a good case for using the While function...?

 I am a bit stuck...

 I am trying to loop through a value list to search for the first instance of a value being greater than X

 eg:

 

for value list

 

"1

2

3

6

7

8

11

15"

 

and X = 10

 

It should return the position of the first value greater than 10, in this case "7" as it is greater than 10

 

What is the best way to do this??

Link to comment
Share on other sites

This is a cross-post: 
https://community.claris.com/en/s/question/0D53w00005Y97ZkCAJ/using-the-while-function-to-search-for-values-greater-than-x
Next time, please include a link to eliminate duplication of effort.

As for the best way to do this, it depends on what is the purpose of this. Your values appear to be sorted in ascending order. We don't know where do they come from; maybe it would be simpler to filter a relationship to get only values that are greater than 10.

We also do not know how many values do you expect. For only a handful of values as in your example, looping over the list until you pass the threshold is reasonable. For larger lists a better strategy would be to start with the middle value and discard either the first or the second half of the list. Then repeat the process with the remaining half and so on.

 

2 hours ago, liltbrockie said:

t should return the position of the first value greater than 10, in this case "7" as it is greater than 10

I believe you meant 11.

Link to comment
Share on other sites

This topic is 891 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.