nustack
ReferenceNuformscollectionsabc

collection

Collection capability.

Module nu.forms.collections.abc.collection.

Collection capability.

CollectionForm = Sized + Iterable + Container.

Follows Python's collections.abc.Collection pattern.

NameCallMeaning
CollectionFormCollectionForm()Base for collection values, like collections.abc.Collection.

CollectionForm

Base for collection values, like collections.abc.Collection.

CollectionForm()

Path nu.forms.collections.abc.CollectionForm.

Combines len() from SizedForm, contains() from ContainerForm, and the result-wrapping infrastructure from IterableForm.

Example

nu.run(nu.List([1, 2, 3]).len())[0]
3

Methods

.extract()

Materialise the full subtree rooted at self.

Builds object.

Yields

The materialised Python value. Preserves EMPTY vs INVALID when self is a sentinel rather than collapsing them together.

Notes

  • Recursively pulls the whole subtree out of the fabric into a plain Python value (dict / list / nested mix), unlike a plain read which only yields the value at self's own address.
  • Needs self bound in a live fabric; it isn't a scalar expression nu.run can evaluate on its own.

Example

nu.List([1, 2, 3]).extract()

Inherited methods

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

From builtins.object:

CallBuildsMeaning
a < bReturn self<value.
a <= bReturn self<=value.
a == bReturn self==value.
a != bReturn self!=value.
a > bReturn self>value.
a >= bReturn self>=value.

On this page