tech:notes_go_lang_programmation_fonctionnelle
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_go_lang_programmation_fonctionnelle [2026/04/13 22:27] – créée Jean-Baptiste | tech:notes_go_lang_programmation_fonctionnelle [2026/05/10 18:03] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag>go Lang}} | ||
| + | |||
| + | # Notes go lang programmation fonctionnelle | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Voir aussi Expr : | ||
| + | * https:// | ||
| + | |||
| + | Voir aussi : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ## map | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | |||
| + | ~~~go | ||
| + | package main | ||
| + | |||
| + | import " | ||
| + | |||
| + | //type f_ii func(int) int | ||
| + | |||
| + | //func MapInt(f f_ii, l []int) [](int) { | ||
| + | func MapInt(f func(int) int, 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, | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Voir aussi | ||
| + | |||
| + | |||
| + | ~~~go | ||
| + | package main | ||
| + | |||
| + | import " | ||
| + | type FuncType func(int) int | ||
| + | |||
| + | func square(x int) int { | ||
| + | return x * x } | ||
| + | |||
| + | var f FuncType = FuncType(square) | ||
| + | |||
| + | func main() { | ||
| + | | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | |||
| + | ~~~go | ||
| + | func stringInSlice(a string, list []string) bool { | ||
| + | for _, b := range list { | ||
| + | if b == a { | ||
| + | return true | ||
| + | } | ||
| + | } | ||
| + | return false | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | FIXME | ||
| + | |||
