Skip to content

Commit

Permalink
add Scan function
Browse files Browse the repository at this point in the history
  • Loading branch information
hsldymq committed Mar 28, 2024
1 parent ac938ac commit 32e00ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion funcs_aggregation.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package handy

import "github.com/hsldymq/goiter"
import (
"github.com/hsldymq/goiter"
)

func Reduce[T, R any](e Iterable[T], init R, reducer func(R, T) R) R {
return goiter.Fold(e.Iter(), init, reducer)
}

func Scan[T, R any](e Iterable[T], init R, folder func(R, T) R) Enumerable[R] {
return newEnumerator(goiter.Scan(e.Iter(), init, folder))
}

0 comments on commit 32e00ca

Please sign in to comment.