https://github.com/klaidliadon/next
A combinatorics package for Go
https://github.com/klaidliadon/next
combinatorics permutation repetition
Last synced: about 1 month ago
JSON representation
A combinatorics package for Go
- Host: GitHub
- URL: https://github.com/klaidliadon/next
- Owner: klaidliadon
- License: mit
- Created: 2015-09-04T09:36:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-11-17T09:30:00.000Z (4 months ago)
- Last Synced: 2025-12-16T02:42:34.364Z (3 months ago)
- Topics: combinatorics, permutation, repetition
- Language: Go
- Size: 32.2 KB
- Stars: 15
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Next
[](https://godoc.org/klaidliadon.dev/next)
[](https://travis-ci.org/klaidliadon/next)
[](https://codecov.io/github/klaidliadon/next?branch=master)
The package calculates asynchronously combinations and permutations of a collection of values.
To add the package recommended:
```sh
go get klaidliadon.dev/next
```
## Functionalities
- Combinations
- Combinations with repetitions
- Permutations
- Permutations with repetitions
## Usage
Just use create a new channel using `Combination()` or `Permutation()` and receive the results.
```go
package main
import (
"fmt"
"klaidliadon.dev/next"
)
func main() {
for v := range next.Combination([]int{1,2,3,4}, 2, true) {
fmt.Println(v)
}
}
```
Produces
```
[1 1]
[1 2]
[1 3]
[1 4]
[2 2]
[2 3]
[2 4]
[3 3]
[3 4]
[4 4]
```
## Roadmap
The 4 main cases of combinatronics are covered:
- [x] Combinations
- [x] Combinations with repetitions
- [x] Permutations
- [x] Permutations with repetitions
The future updates will improve performance and memory usage.