Documentation

Init.Data.Iterators.Consumers.Collect

Collectors #

This module provides consumers that collect the values emitted by an iterator in a data structure. Concretely, the following operations are provided:

Some operations are implemented using the IteratorCollect type class.

@[inline]
def Std.Iterators.Iter.toArray {α β : Type w} [Iterator α Id β] [IteratorCollect α Id Id] (it : Iter β) :

Traverses the given iterator and stores the emitted values in an array.

If the iterator is not finite, this function might run forever. The variant it.ensureTermination.toArray always terminates after finitely many steps.

Equations
Instances For
    @[inline, deprecated Std.Iterators.Iter.toArray (since := "2025-12-04")]

    Traverses the given iterator and stores the emitted values in an array.

    This function is deprecated. Instead of it.allowNontermination.toArray, use it.toArray.

    Equations
    Instances For
      @[inline]
      def Std.Iterators.Iter.Total.toArray {α β : Type w} [Iterator α Id β] [Finite α Id] [IteratorCollect α Id Id] (it : Total β) :

      Traverses the given iterator and stores the emitted values in an array.

      This variant terminates after finitely many steps and requires a proof that the iterator is finite. If such a proof is not available, consider using Iter.toArray.

      Equations
      Instances For
        @[inline]
        def Std.Iterators.Iter.toListRev {α β : Type w} [Iterator α Id β] (it : Iter β) :
        List β

        Traverses the given iterator and stores the emitted values in reverse order in a list. Because lists are prepend-only, this toListRev is usually more efficient that toList.

        If the iterator is not finite, this function might run forever. The variant it.ensureTermination.toListRev always terminates after finitely many steps.

        Equations
        Instances For
          @[inline, deprecated Std.Iterators.Iter.toListRev (since := "2025-12-04")]
          def Std.Iterators.Iter.Partial.toListRev {α β : Type w} [Iterator α Id β] (it : Partial β) :
          List β

          Traverses the given iterator and stores the emitted values in reverse order in a list. Because lists are prepend-only, this toListRev is usually more efficient that toList.

          This function is deprecated. Instead of it.allowNontermination.toListRev, use it.toListRev.

          Equations
          Instances For
            @[inline]
            def Std.Iterators.Iter.Total.toListRev {α β : Type w} [Iterator α Id β] [Finite α Id] (it : Total β) :
            List β

            Traverses the given iterator and stores the emitted values in reverse order in a list. Because lists are prepend-only, this toListRev is usually more efficient that toList.

            This variant terminates after finitely many steps and requires a proof that the iterator is finite. If such a proof is not available, consider using Iter.toListRev.

            Equations
            Instances For
              @[inline]
              def Std.Iterators.Iter.toList {α β : Type w} [Iterator α Id β] [IteratorCollect α Id Id] (it : Iter β) :
              List β

              Traverses the given iterator and stores the emitted values in a list. Because lists are prepend-only, toListRev is usually more efficient that toList.

              If the iterator is not finite, this function might run forever. The variant it.ensureTermination.toList always terminates after finitely many steps.

              Equations
              Instances For
                @[always_inline, deprecated Std.Iterators.Iter.toList (since := "2025-12-04")]

                Traverses the given iterator and stores the emitted values in a list. Because lists are prepend-only, toListRev is usually more efficient that toList.

                This function is deprecated. Instead of it.allowNontermination.toList, use it.toList.

                Equations
                Instances For
                  @[inline]
                  def Std.Iterators.Iter.Total.toList {α β : Type w} [Iterator α Id β] [Finite α Id] [IteratorCollect α Id Id] (it : Total β) :
                  List β

                  Traverses the given iterator and stores the emitted values in a list. Because lists are prepend-only, toListRev is usually more efficient that toList.

                  This variant terminates after finitely many steps and requires a proof that the iterator is finite. If such a proof is not available, consider using Iter.toList.

                  Equations
                  Instances For