Outils pour utilisateurs

Outils du site


tech:notes_go_lang_programmation_fonctionnelle

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:notes_go_lang_programmation_fonctionnelle [2026/04/13 22:38] Jean-Baptistetech:notes_go_lang_programmation_fonctionnelle [2026/05/10 18:03] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>go Lang}}
 +
 +# Notes go lang programmation fonctionnelle
 +
 +Voir :
 +* https://bitfieldconsulting.com/posts/functional
 +* https://github.com/robpike/filter
 +
 +Voir aussi Expr :
 +* https://buildsoftwaresystems.com/fr/post/go-scripting-expr-lang-gotchas/
 +
 +Voir aussi :
 +* https://pkg.go.dev/maps
 +* https://go.dev/blog/gofix
 +
 +
 +## map
 +
 +Voir :
 +* https://stackoverflow.com/questions/12655464/can-functions-be-passed-as-parameters
 +
 +~~~go
 +package main
 +
 +import "fmt"
 +
 +//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, liste))
 +}
 +~~~
 +
 +
 +Voir aussi
 +
 +
 +~~~go
 +package main
 +
 +import "fmt"
 +                                            type FuncType func(int) int
 +
 +func square(x int) int {
 +    return x * x                            }
 +
 +var f FuncType = FuncType(square)
 +
 +func main() {
 + fmt.Println(f(5))
 +}
 +~~~
 +
 +
 +## Autres
 +
 +
 +~~~go
 +func stringInSlice(a string, list []string) bool {
 +        for _, b := range list {
 +                if b == a {
 +                        return true
 +                }
 +        }
 +        return false
 +}
 +~~~
 +
 +
 +FIXME
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki