Skip to content

PyoReversible

Bases: Reversible[T], ABC


              flowchart TD
              pyochain.abc._sequences.PyoReversible[PyoReversible]

              

              click pyochain.abc._sequences.PyoReversible href "" "pyochain.abc._sequences.PyoReversible"
            
Source code in src/pyochain/abc/_sequences.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class PyoReversible[T](Reversible[T], ABC):
    # pyrefly: ignore [implicit-any-attribute]
    __slots__ = ()  # pyright: ignore[reportUnannotatedClassAttribute]

    def rev(self) -> Iter[T]:
        """Return an `Iterator` with the elements of the `Sequence` in reverse order.

        Returns:
            Iter[T]: An `Iterator` with the elements in reverse order.

        Example:
            ```python
            >>> from pyochain import Seq, Range
            >>> Seq((1, 2, 3)).rev().collect()
            Seq(3, 2, 1)
            >>> Range(0, 5).rev().collect()
            Seq(4, 3, 2, 1, 0)

            ```
        """
        from .._iter import Iter

        return Iter(reversed(self))

rev()

Return an Iterator with the elements of the Sequence in reverse order.

Returns:

Type Description
Iter[T]

Iter[T]: An Iterator with the elements in reverse order.

Example
>>> from pyochain import Seq, Range
>>> Seq((1, 2, 3)).rev().collect()
Seq(3, 2, 1)
>>> Range(0, 5).rev().collect()
Seq(4, 3, 2, 1, 0)
Source code in src/pyochain/abc/_sequences.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def rev(self) -> Iter[T]:
    """Return an `Iterator` with the elements of the `Sequence` in reverse order.

    Returns:
        Iter[T]: An `Iterator` with the elements in reverse order.

    Example:
        ```python
        >>> from pyochain import Seq, Range
        >>> Seq((1, 2, 3)).rev().collect()
        Seq(3, 2, 1)
        >>> Range(0, 5).rev().collect()
        Seq(4, 3, 2, 1, 0)

        ```
    """
    from .._iter import Iter

    return Iter(reversed(self))