Skip to content

Unzipped

Bases: Pipeable, Checkable

Represents the result of unzipping an Iter of pairs into two separate Iter.

See Also

Iter.unzip()

Example:

>>> import pyochain as pc
>>> pairs = pc.Iter(((1, 'a'), (2, 'b'), (3, 'c')))
>>> unzipped = pairs.unzip()
>>> unzipped.left.collect()
Seq(1, 2, 3)

Source code in src/pyochain/_iter.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@dataclass(slots=True)
class Unzipped[T, V](Pipeable, Checkable):
    """Represents the result of unzipping an `Iter` of pairs into two separate `Iter`.

    See Also:
        `Iter.unzip()`
    Example:
    ```python
    >>> import pyochain as pc
    >>> pairs = pc.Iter(((1, 'a'), (2, 'b'), (3, 'c')))
    >>> unzipped = pairs.unzip()
    >>> unzipped.left.collect()
    Seq(1, 2, 3)

    ```
    """  # noqa: DOC601, DOC603

    left: Iter[T]
    """An `Iter` over the first elements of the pairs."""
    right: Iter[V]
    """An `Iter` over the second elements of the pairs."""

    def __bool__(self) -> bool:
        return bool(self.left) and bool(self.right)

left instance-attribute

An Iter over the first elements of the pairs.

right instance-attribute

An Iter over the second elements of the pairs.