Not-every quantifier

Learn how to check if any item does not meet a condition.

This quantifier checks whether at least one element in a collection does not satisfy a given condition.

Note that the result is always false for empty collections. This is because there is not a single element in the collection that does not satisfy the condition.

Syntax

This quantifier has the following syntax:

not every /*<item>*/ in /*<collection>*/ satisfies /*<condition>*/
Try in Playground

Either satisfy or satisfies can be used interchangeably:

not every /*<item>*/ in /*<collection>*/ satisfy /*<condition>*/
Try in Playground

You can also specify a name to refer to the index of the element in the collection:

not every /*<item>*/ in /*<collection>*/ indexed by /*<index>*/ satisfies /*<condition>*/
Try in Playground

You must replace the /*<item>*/ and /*<index>*/ placeholders with a valid identifier. These variables will refer to the element and its index in the collection, as exemplified in the following section.

Examples

Here is an example that checks if there is at least one number in a collection that is not even:

not every number in [2, 4, 6] satisfies number mod 2 is 0 // false
Try in Playground

The following example shows how to use the index of the element in the condition:

not every item in cart indexed by index satisfies item's brand is "Apple" and index >= 1
Try in Playground

In the above example, it checks whether the user added at least one non-Apple product as the second or subsequent item in the cart.