YTSFlix_Go/vendor/github.com/anacrolix/missinggo/iter/head.go
2018-11-04 15:58:15 +01:00

17 lines
203 B
Go

package iter
func Head(n int, f Func) Func {
return func(cb Callback) {
if n <= 0 {
return
}
f(func(v interface{}) bool {
n--
if !cb(v) {
return false
}
return n > 0
})
}
}