len

Module

Provides the len function.

These are Mojo built-ins, so you don’t need to import them.

len

len[type: DType, size: Int](value: SIMD[type, size]) -> Int

Returns the length of the given SIMD value.

Parameters:

  • type (DType): The element type of the SIMD value.
  • size (Int): The number of elements in the value.

Args:

  • value (SIMD[type, size]): The SIMD value.

Returns:

The length of the SIMD value.

len[size: Int, type: AnyType](value: InlinedFixedVector[size, *"type"]) -> Int

Returns the length of the given fixed vector.

Parameters:

  • size (Int): The number of elements in the value.
  • type (AnyType): The element type of the value.

Args:

  • value (InlinedFixedVector[size, *"type"]): The vector value.

Returns:

The length of the vector.

len[type: AnyType](value: UnsafeFixedVector[*"type"]) -> Int

Return the length of the given vector.

Parameters:

  • type (AnyType): The element type of the value.

Args:

  • value (UnsafeFixedVector[*"type"]): The vector value.

Returns:

The length of the vector.

len[type: AnyType](value: DynamicVector[*"type"]) -> Int

Return the length of the given vector.

Parameters:

  • type (AnyType): The element type of the value.

Args:

  • value (DynamicVector[*"type"]): The vector value.

Returns:

The length of the vector.

len(value: String) -> Int

Return the length of the given string.

Args:

  • value (String): The string value.

Returns:

The length of the string.

len(value: StringRef) -> Int

Return the length of the given string reference.

Args:

  • value (StringRef): The string value.

Returns:

The length of the string.

len(value: StringLiteral) -> Int

Return the length of the given string literal.

Args:

  • value (StringLiteral): The string literal value.

Returns:

The length of the string literal.

len[size: Dim, type: DType](value: Buffer[size, type]) -> Int

Return the length of the given buffer.

Parameters:

  • size (Dim): The number of elements in the value.
  • type (DType): The element type of the value.

Args:

  • value (Buffer[size, type]): The buffer value.

Returns:

The length of the buffer.

len[type: AnyType](value: VariadicList[*"type"]) -> Int

Return the length of the given variadic list.

Parameters:

  • type (AnyType): The element type of the value.

Args:

  • value (VariadicList[*"type"]): The variadic list value.

Returns:

The length of the variadic list.

len[type: AnyType](value: VariadicListMem[*"type"]) -> Int

Return the length of the given variadic list.

Parameters:

  • type (AnyType): The element type of the value.

Args:

  • value (VariadicListMem[*"type"]): The variadic list value.

Returns:

The length of the variadic list.

len[*types: AnyType](value: ListLiteral[types]) -> Int

Return the length of the given list literal.

Parameters:

  • types (*AnyType): The element types of the value.

Args:

  • value (ListLiteral[types]): The list literal value.

Returns:

The length of the list literal.

len[*types: AnyType](value: Tuple[types]) -> Int

Return the length of the given tuple literal.

Parameters:

  • types (*AnyType): The element types of the value.

Args:

  • value (Tuple[types]): The tuple literal value.

Returns:

The length of the tuple literal.

len[size: Int](value: StaticIntTuple[size]) -> Int

Return the length of the given static tuple.

Parameters:

  • size (Int): The number of elements in the value.

Args:

  • value (StaticIntTuple[size]): The static tuple value.

Returns:

The length of the static tuple.