fp
所属分类:collect
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-10-20 13:22:53
上 传 者:
sh-1993
说明: Go函数编程库
(Go functional programming library)
文件列表:
fp.go (11296, 2023-12-19)
fp_test.go (5374, 2023-12-19)
go.mod (221, 2023-12-19)
go.sum (881, 2023-12-19)
set/ (0, 2023-12-19)
set/sets.go (905, 2023-12-19)
set/sets_test.go (616, 2023-12-19)
# Go functional programming library based on generics
This library introduces various functional programming miscellaneous that are
useful in a number of scenarious. It aims to both provide some long-awaited
sugar and examine the limits of recentely introduced Go generics. Implemented
functions and types are partially inspired by Haskell Prelude.
- reduce (foldl)
- map
- filter
- zip
- find
- Predicates and curried comparisment functions: IsZero, Eq, NEq, Lt, LtEq, Gt, GtEq
- all
- any
- minimum
- maximum
- sum
- product
The package isn't intended to completely implement the Prelude, but rather it's an
useful tool for some casual issues like the following:
```go
type StorageTimeModel struct{
Time time.Time
}
type TransportTimeModel struct {
Time int64
}
func RPC_GetTimeseries() []TransportTimeModel {
var series []StorageTimeModel = storage.GetTimeSeries()
return fp.Map(func(e StorageTimeModel) TransportTimeModel {
return TransportTimeModel{
Time: e.Time.Unix(),
}
}, series...)
}
```
近期下载者:
相关文件:
收藏者: