billderose-zz / higher

Higher order functions for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Higher

Higher order functions in Go (really unsafe). You probably shouldn't use this.

s1 := []int{1, 2, 3, 4, 5}
s2 := higher.Filter(s1, func(x int) bool { return x > 2 })
s3 := higher.Map(s, strconv.Itoa).([]string)

You can chain them too.

s := higher.Wrap([]int{1, 2, 3, 4, 5}).
        Filter(s1, func(x int) bool { return x > 2 }).
        Map(s, strconv.Itoa).
        Val().([]string)

Available functions:

  • Map
  • Filter
  • Reduce
  • ForEach
  • Tap
  • Any
  • Every
  • Contains
  • Find

Chaining

  • Wrap
  • Val

About

Higher order functions for Go