README ¶ functional-go Expand ▾ Collapse ▴ Documentation ¶ Index ¶ func FoldLeft[FA Foldable[A], A any, B any](foldable FA, initial B, foldFn func(elem A, state B) B) B type FoldLeftFn type Foldable type Monoid type Semigroup type Slice func (s Slice[A]) FoldLeft(fn FoldLeftFn[A]) Examples ¶ Slice.FoldLeft Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func FoldLeft ¶ func FoldLeft[FA Foldable[A], A any, B any](foldable FA, initial B, foldFn func(elem A, state B) B) B Types ¶ type FoldLeftFn ¶ type FoldLeftFn[A any] interface { Next(elem A) } type Foldable ¶ type Foldable[A any] interface { FoldLeft(fn FoldLeftFn[A]) } type Monoid ¶ type Monoid[A any] interface { Semigroup[A] Empty() A } type Semigroup ¶ type Semigroup[A any] interface { Combine(x A, y A) A } type Slice ¶ type Slice[A any] []A func (Slice[A]) FoldLeft ¶ func (s Slice[A]) FoldLeft(fn FoldLeftFn[A]) Example ¶ s := Slice[int]{1, 2, 3, 4} r := FoldLeft(s, 10, func(elem int, state int) int { fmt.Println(elem, state) return elem + state }) fmt.Println("=", r) Output: 1 10 2 11 3 13 4 16 = 20 Source Files ¶ View all Source files fold.gomonoid.goslice.go Directories ¶ Show internal Expand all Path Synopsis collections heterogeneous/hlist heterogeneous/hmap immutable immutable/chain immutable/cursor immutable/list lists maps sets eval funcs monads effects identity option result rx subscriptions types typelists Package typelists allows representing list of types on the type level. Package typelists allows representing list of types on the type level. Click to show internal directories. Click to hide internal directories.