Notes go lang programmation fonctionnelle

map

package main import "fmt" type f_ii func(int) int func MapInt(f f_ii, l []int) [](int) { ret := []int{} for _, v := range l { ret = append(ret, f(v)) } return (ret) } func carre(i int) int { return i * i } func main() { liste := []int{1, 2, 3} fmt.Println(MapInt(carre, liste)) }