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).

any

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

Checks whether any element in the iterable is truthy.

Checks elements in order and stops at the first truthy element. An empty iterable returns False.

For example:

print(any([0, 0, 5])) # True
print(any([0, 0, 0])) # 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 any element is truthy, False otherwise.

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

Checks if any element in the iterable is truthy, consuming the iterable.

Args:

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

Returns:

Bool: True if any element in the iterable is truthy, False otherwise.

def any(value: SIMD) -> Bool

Checks whether any element in the SIMD vector is truthy.

For example:

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

Args:

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

Returns:

Bool: True if any element is truthy, False otherwise.