Help us shape the future of Go! Take the 2026 Go Developer Survey

permutations

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

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

Go to latest
Published: Mar 1, 2018 License: MIT Imports: 1 Imported by: 0

README

permutations

Go functions for fast generation of the array of permutations of a set. This are implementations having only n! assignments accessing the memory and smallest number of calls to make. All other operation work on local variables. The implementation works recursively. The result of a recursion is already at the right position, so no further operation is needed.

There are two versions: one which should be theorethically be faster, returning an unsorted array, and one which returns a sorted array. For larger sets the sorted version shows better benchmark results.

GoDoc

This project is licensed under the terms of the MIT license.

Documentation

Overview

Package permutations is library of functions to create permutations

Ralf Poeppel 2018

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnumerateInterval

func EnumerateInterval(low, high int) []int

EnumerateInterval enumerate the integers in an intervall, s. sicp chapter 2.2.3

func Faculty

func Faculty(n int) int64

Faculty calculates the value of faculty(n)

func GeneratePermutations

func GeneratePermutations(values []interface{}) [][]interface{}

GeneratePermutations generates the permutations of an array of values. The rows of the array are not sorted. This is the fastest algorithm in this package.

func GeneratePermutationsSorted

func GeneratePermutationsSorted(values []interface{}) [][]interface{}

GeneratePermutationsSorted generate an array with all permutations of an array of values and maintain the sort order of the array.

Types

This section is empty.

Jump to

Keyboard shortcuts

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