next

package module
v0.0.0-...-ed266f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2019 License: MIT Imports: 1 Imported by: 0

README

Next

GoDoc Build Status codecov.io

The package calculates asynchronously combinations and permutations of a collection of values.

To add the package recommended:

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.

package main

import (
	"fmt"
	"klaidliadon.dev/next"
)

func main() {
	for v := range next.Combination([]interface{}{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:

  • Combinations
  • Combinations with repetitions
  • Permutations
  • Permutations with repetitions

The future updates will improve performance and memory usage.

Documentation

Overview

Package next calculates asynchronously combinations and permutations of a collection of values.

Here is a sample usage of next:

package main

import (
	"fmt"
	"klaidliadon.dev/next"
)

func main() {
	for v := range next.Combination([]interface{1,2,3,4}, 2, true) {
		fmt.Println(v)
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combination

func Combination(base []interface{}, n int, repeat bool) <-chan []interface{}

Returns a channel of combinantions of n element from base w/o repetition

func Permutation

func Permutation(base []interface{}, n int, repeat bool) <-chan []interface{}

Returns a channel of permutations of n element from base w/o repetition

Types

This section is empty.

Directories

Path Synopsis
Command line utility to generate combinations and permutations using next library.
Command line utility to generate combinations and permutations using next library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL