Predicates
We can use predicates to perform operations on input data. Predicates can be used to implement many of the functions that we apply to collections to transform input data into the result collection or value.
Note
Thepredicate
 function is a function that takes one item as input and returns either true or false, based on whether the item satisfies some condition. They are often used conditionally to determine whether to apply certain operations in the execution chain.
Let's create some predicate functions that we can use to manipulate a collection of cars.
The All()
function returns true
only if all the values in the collection satisfy the predicate
condition:
package predicate func All(vals []string, predicate func(string) bool) bool { for _, val := range vals { if !predicate(val) { return false } } return true }
The Any()
 function returns true
as long as any one of the values in the collection satisfies the predicate
condition:
funcAny(vs []string, predicate func...