Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/owainlewis/hof
Higher order functions for Golang
https://github.com/owainlewis/hof
collections functional-programming golang higher-order-functions
Last synced: about 1 month ago
JSON representation
Higher order functions for Golang
- Host: GitHub
- URL: https://github.com/owainlewis/hof
- Owner: owainlewis
- Created: 2018-12-14T20:27:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-14T20:53:19.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T13:29:33.100Z (5 months ago)
- Topics: collections, functional-programming, golang, higher-order-functions
- Language: Go
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HOF
HOF is a set of higher order function utilities for working with core Golang types.
Golang looping constructs can often lead to verbose, hard to read code. This library makes
basic data transformation tasks easier to reason about whilst still maintaining good performance.This library uses code generation rather than reflection so there should be no performance hit when
using these utilities.## Example
```go
package mainimport (
"fmt"
"github.com/owainlewis/hof/pkg/collections"
)func main() {
data := []int{1, 2, 3, 4, 5}dl := collections.
NewIntList(data).
Filter(func(n int) bool { return n > 3 }).
Map(func(n int) int { return n + 1 }).
Get()fmt.Printf("Result %v\n", dl)
}
```## Map
## Filter
## Select
## Take
## Any
## All
## Reduce