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.
 
 
 
 

751 B

map

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.

Fonction attendue

func Map(f func(int) bool, arr []int) []bool {

}

Utilisation

Voici un éventuel programme pour tester votre fonction :

package main

import (
	"fmt"
	piscine ".."
)

func main() {
	arr := []int{1, 2, 3, 4, 5, 6}
	result := piscine.Map(piscine.IsPrime, arr)
	fmt.Println(result)
}

Et son résultat :

student@ubuntu:~/[[ROOT]]/test$ go build
student@ubuntu:~/[[ROOT]]/test$ ./test
[false true true false true false]
student@ubuntu:~/[[ROOT]]/test$