Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using the while function to search for values greater than X

Featured Replies

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??

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.

  • Author

Hey Comment thanks for the reply!

Yes there is a rather nice solution in the cross post...! All sorted now thanks

I did mean "7" as I wanted to return the position.. not the value!

1 minute ago, liltbrockie said:

I did mean "7" as I wanted to return the position.. not the value!

Ah. My fault, then, for not reading closely enough.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.