IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

all

def all[IterableType: Iterable](iterable: IterableType) -> Bool where conforms_to(IterableType.IteratorType[iterable].Element, Boolable & Deinitable)

Checks whether all elements in the iterable are truthy.

Checks elements in order and stops at the first falsy element. An empty iterable returns True.

For example:

print(all([1, 2, 3])) # True
print(all([1, 0, 3])) # False

Parameters:

  • ​IterableType (Iterable): The type of the iterable. Its elements must conform to Boolable and Deinitable.

Args:

  • ​iterable (IterableType): The iterable to check.

Returns:

Bool: True if all elements are truthy, False otherwise.

def all(var iterable: T) -> Bool where conforms_to(T.IteratorOwnedType.Element, Boolable & Deinitable)

Checks if all elements in the iterable are truthy, consuming the iterable.

Args:

  • ​iterable (T): The iterable to consume and check.

Returns:

Bool: True if all elements in the iterable are truthy, False otherwise.

def all(value: SIMD) -> Bool

Checks whether all elements in the SIMD vector are truthy.

For example:

var flags = SIMD[.bool, 4](True, True, True, False)
print(all(flags)) # False

Args:

  • ​value (SIMD): The SIMD vector to check.

Returns:

Bool: True if all elements are truthy, False otherwise.