https://github.com/icholy/higher
Higher order functions for Go
https://github.com/icholy/higher
Last synced: 3 months ago
JSON representation
Higher order functions for Go
- Host: GitHub
- URL: https://github.com/icholy/higher
- Owner: icholy
- Created: 2014-01-09T18:34:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-12T20:58:47.000Z (about 10 years ago)
- Last Synced: 2025-04-13T17:13:25.362Z (3 months ago)
- Language: Go
- Size: 229 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Higher [](https://travis-ci.org/icholy/higher)
> Higher order functions in Go (really unsafe).
> You probably shouldn't use this.[godoc](http://godoc.org/github.com/icholy/higher)

### Examples
``` go
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.
``` go
s := higher.Wrap([]int{1, 2, 3, 4, 5}).
Filter(func(x int) bool { return x > 2 }).
PMap(strconv.Itoa).
Tap(fmt.Println).
Val().([]string)
```### Available functions:
* `Map`
* `PMap`
* `Filter`
* `PFilter`
* `Reduce` reduce can't be parallel
* `ForEach`
* `PForEach`
* `Tap`
* `PTap`
* `Any`
* `PAny`
* `Every`
* `PEvery`
* `Contains`
* `PContains`
* `Find`
* `PFind`### Chaining
* `Wrap`
* `Val`