Tinderbox v11 Icon

list.every(loopVar, expressionStr)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Data Type Returned: 

Operator First Added: 

Operator in Current Baseline: 

Operator Last Altered: 

Operator Uses Loop Variable Argument: 

 Function  [other Function type actions]

 List  [operators of similar scope]

 Query Boolean  [other Query Boolean operators]

 boolean test

 v8.1.0

 Baseline

 As at baseline

 [More on loop variable arguments]


list.every(loopVar, expressionStr)

This is true if every loopVar in the List- or Set-type list meets the query in expressionStr. Thus:

$MyList.every(x,x>5) 

is true if every loopVar in $MyList is greater than 5.

The comparison may also be applied to literal lists:

"apple; pear; plum".every(x, x>"aardvark") 

is true because every element follows "aardvark" in alphabetical (lexical sort) order.

If the target list or set is empty, .any() always returns false, and .every() always returns true.

The loopVar is a user-set case-sensitive string. "x", "anItem", etc., are equally applicable. Similar to a loop variable in .each(x){}, the point of the loopVar value, is to set a reference variable for each list element. This can then be used in the code provided by the expressionStr argument. Using a number for loopVar, e.g. '1' or '42' is not recommended. Choose a value that makes sense for your own style of work

The expressionStr is any action code expression that is a test resolving to a Boolean true/false answer (i.e. a query). For example, to test if every item exactly matches the value stored in the $MyString of 'Some note':

$MyBoolean = $MyList.every(anItem, anItem == $MyString("Some Note")); 

Or, every list value starts with the string 'Large':

$MyBoolean = $MyList.every(Z, Z.contains("^ large")); 

See also—notes linking to here: