MCPcopy Create free account
hub / github.com/Soft/iter / ForEach

Function ForEach

iterator.go:324–330  ·  view source on GitHub ↗

ForEach consumes the Iterator applying fn to each yielded value.

(it Iterator[T], fn func(T))

Source from the content-addressed store, hash-verified

322
323// ForEach consumes the Iterator applying fn to each yielded value.
324func ForEach[T any](it Iterator[T], fn func(T)) {
325 v := it.Next()
326 for v.IsSome() {
327 fn(v.Unwrap())
328 v = it.Next()
329 }
330}
331
332// Fold reduces Iterator using function fn.
333func Fold[T any, B any](it Iterator[T], init B, fn func(B, T) B) B {

Callers 3

TestForEachFunction · 0.85
ToSliceFunction · 0.85
FoldFunction · 0.85

Calls 3

IsSomeMethod · 0.80
UnwrapMethod · 0.80
NextMethod · 0.65

Tested by 1

TestForEachFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…