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.

42 lines
757 B

5 years ago
## map
5 years ago
### Instructions
Écrire une fonction `Map` qui, pour un tableau d'`int`, applique une fonction de type `func(int) bool` sur chaque éléments de ce tableau et retournes un tableau de toutes les valeurs de retour.
5 years ago
### Fonction attendue
```go
func Map(f func(int) bool, arr []int) []bool {
5 years ago
}
```
5 years ago
### Utilisation
Voici un éventuel [programme](TODO-LINK) pour tester votre fonction :
```go
package main
import (
"fmt"
piscine ".."
)
func main() {
arr := []int{1, 2, 3, 4, 5, 6}
5 years ago
result := piscine.Map(piscine.IsPrime, arr)
fmt.Println(result)
}
```
Et son résultat :
```console
student@ubuntu:~/piscine-go/test$ go build
student@ubuntu:~/piscine-go/test$ ./test
[false true true false true false]
student@ubuntu:~/piscine-go/test$
```