Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/icholy/higher

Higher order functions for Go
https://github.com/icholy/higher

Last synced: 1 day ago
JSON representation

Higher order functions for Go

Awesome Lists containing this project

README

        

# Higher [![Build Status](https://travis-ci.org/icholy/higher.png?branch=master)](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)

![](higher.jpeg)

### 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`