https://github.com/alexandrelamarre/ro
😎 A generic iterator Go library based on Go 1.23+ rangefunc, built for composability and readability
https://github.com/alexandrelamarre/ro
functional generic go golang iterator typesafe
Last synced: about 1 month ago
JSON representation
😎 A generic iterator Go library based on Go 1.23+ rangefunc, built for composability and readability
- Host: GitHub
- URL: https://github.com/alexandrelamarre/ro
- Owner: alexandreLamarre
- License: apache-2.0
- Created: 2024-04-24T14:54:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-26T21:33:06.000Z (about 1 month ago)
- Last Synced: 2025-04-26T22:26:13.697Z (about 1 month ago)
- Topics: functional, generic, go, golang, iterator, typesafe
- Language: Go
- Homepage:
- Size: 74.2 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ro


[](https://pkg.go.dev/github.com/alexandreLamarre/ro)
[](https://github.com/alexandreLamarre/ro/actions/workflows/lint.yaml)
[](https://github.com/alexandreLamarre/ro/actions/workflows/test.yaml)
[](https://codecov.io/gh/alexandreLamarre/ro)
[](./LICENSE)`alexandreLamarre/ro` (short for "range-over") is a generic iterator Go library based on Go 1.22+ [rangefunc](https://go.dev/wiki/RangefuncExperiment) experiment.
The library is built for composability and readibility while providing similar functionality to other language's interator libraries such as [itertools](https://docs.python.org/3/library/itertools.html)
This library is intended to be paired with [`samber/lo`](https://github.com/samber/lo), where applicable.
## 🚀 Install
```sh
go get github.com/alexandreLamarre/[email protected]
```## ✔️ Requirements
This library requires you to use go 1.23.X or greater.
## 💡 Usage
You can import `ro` using:
```go
import (
"github.com/alexandreLamarre/ro"
)
```## 👀 Example
```go
it := ro.Drop(
ro.Apply(
ro.Limit(
ro.Permutations(
ro.ToSlice(
ro.Range(0, 6, 1),
),
5,
),
5,
),
func(perm []int) int {
return digitsToInt(perm)
},
),
func(i int) bool {
return i > 10000
},
)
for v := range it {
fmt.Println(v)
}
```yields the following output:
```sh
1234
2134
```The above iterator yields all numbers < 10000 that are formed from the digits of the first 5 generated permutations of {0,1,2,3,4,5} of size 5