YTSFlix_Go/vendor/github.com/anacrolix/missinggo/iter/head.go

17 lines
203 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
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
})
}
}