Documentation

Init.Data.List.Scan.Basic

@[inline]
def List.scanlM {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (init : β) (l : List α) :
m (List β)

Folds a monadic function over a list from the left, accumulating partial results starting with init. The accumulated values are combined with the each element of the list in order, using f.

Equations
Instances For
    @[inline]
    def List.scanrM {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (xs : List α) :
    m (List β)

    Folds a monadic function over a list from the right, accumulating partial results starting with init. The accumulated values are combined with the each element of the list in order, using f.

    Equations
    Instances For
      @[inline]
      def List.scanl {β : Type u_1} {α : Type u_2} (f : βαβ) (init : β) (as : List α) :
      List β

      Fold a function f over the list from the left, returning the list of partial results.

      scanl (+) 0 [1, 2, 3] = [0, 1, 3, 6]
      
      Equations
      Instances For
        @[inline]
        def List.scanr {α : Type u_1} {β : Type u_2} (f : αββ) (init : β) (as : List α) :
        List β

        Fold a function f over the list from the right, returning the list of partial results.

        scanr (+) 0 [1, 2, 3] = [6, 5, 3, 0]
        
        Equations
        Instances For