/combinations

Go lang combination package.

Primary LanguageGo

Combinations

A package with combinations functions from python itertools. For now the following iterators are implemented :

  • Product (the Cartesian product).
  • Permutation (basing on the Product result).
  • Combination.
  • Combination with replacement.

Installation

Just go get this repository with the following way:

go get github.com/alexpantyukhin/combinations

Usage

package main

import (
    "fmt"
    "github.com/alexpantyukhin/combinations"
)

func main() {
    inter := []interface{}{0, 1, 2}
    product, _ := combinations.NewProduct(inter, 3)

    for product.Next() {
        fmt.Println(product.Value())
    }
}