All Is True

Examples in Go
package main

import (
    "fmt"
    "strings"
)

func All(vs []string, f func(string) bool) bool {
    for _, v := range vs {
        if !f(v) {
            return false
        }
    }
    return true
}

func main() {

    var strs = []string{"peach", "apple", "pear", "plum"}

    fmt.Println(All(strs, func(v string) bool {
        return strings.HasPrefix(v, "p")
    }))
}
Last Run  :
false