mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
12 lines
326 B
Go
12 lines
326 B
Go
package underscore
|
|
|
|
// All returns true if all the values in the slice pass the predicate truth test.
|
|
// Short-circuits and stops traversing the slice if a false element is found.
|
|
func All[T any](values []T, predicate func(T) bool) bool {
|
|
for _, v := range values {
|
|
if !predicate(v) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|