some()¶
Info
New in Atfinity 17.
Description¶
some() checks a condition against each element of a list and returns true as soon as one element satisfies it.
It stops at that element, so the rest of the list is never evaluated.
Use it instead of SOME whenever the condition has to be written out.
SOME tests the values it is handed, so expressing a condition with it takes a map() first:
list.some(x => x = 'high') and SOME(list.map(x => x = 'high')) answer the same question, and the first states the
condition once.
If you need every element to satisfy the condition instead, use every().
Syntax¶
Returns: true or false, or unknown if the list itself is unknown.
Example¶
This returns true, since 3 is greater than 2.
This returns true if the person holds a passport from any of the three countries.
Empty lists¶
[].some(number => number > 0) evaluates to false.
See the SOME page for the rationale, which is the same one.