A simple Go library that provides various functional programming features.
- Lightweight
- No dependencies
- No custom types
go get github.com/Wing924/go-fn
package main
import (
"fmt"
"github.com/Wing924/go-fn"
)
func main() {
slice := []int{1, 2, 3}
// Map
result := fn.Map(slice, func(i int) int {
return i * 2
})
fmt.Println(result) // [2 4 6]
// Reduce
sum := fn.Reduce(slice, 0, func(acc, i int) int {
return acc + i
})
fmt.Println(sum) // 6
}