Any Is True
Examples in
Go
package main
import (
"fmt"
"strings"
)
func Any(vs []string, f func(string) bool) bool {
for _, v := range vs {
if f(v) {
return true
}
}
return false
}
func main() {
var strs = []string{"peach", "apple", "pear", "plum"}
fmt.Println(Any(strs, func(v string) bool {
return strings.HasPrefix(v, "p")
}))
}
Last Run
:
true