November 10, 20214 yr 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??
November 10, 20214 yr 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.
November 10, 20214 yr 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!
November 10, 20214 yr 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