mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xpetit
32eddefd09
|
4 years ago | |
---|---|---|
.. | ||
README.md | 4 years ago |
README.md
any
Instructions
Write a function Any
that returns true
, for a string
slice :
- if, when that
string
slice is passed through anf
function, at least one element returnstrue
.
Expected function
func Any(f func(string) bool, a []string) bool {
}
Usage
Here is a possible program to test your function :
package main
import (
"fmt"
piscine ".."
)
func main() {
a1 := []string{"Hello", "how", "are", "you"}
a2 := []string{"This", "is", "4", "you"}
result1 := piscine.Any(piscine.IsNumeric, a1)
result2 := piscine.Any(piscine.IsNumeric, a2)
fmt.Println(result1)
fmt.Println(result2)
}
And its output :
student@ubuntu:~/any/test$ go build
student@ubuntu:~/any/test$ ./test
false
true
student@ubuntu:~/any/test$