prand

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoinFlip

func CoinFlip() bool

Heads = true

func CoinFlipBias

func CoinFlipBias(bias float64) bool

Provide desired win % for heads (heads = true). CoinFlipBias(51) would imply heads should win 51% of the time.

func FloatN

func FloatN(n float64) float64

Generates a pseudo-random float, where 0.0 <= x < `n`.

func IntN

func IntN(n int) int

Generates a pseudo-random int, where 0 <= x < `n`.

func SliceSubsets

func SliceSubsets(sLen, strLen int, bias float64) (parent []string, child []string)

Uses `StringSlice` to generate a slice of strings. Then the bias parameter is passed to `CoinFlipBias` for each string in the set to produce a child slice containing a subset of the parent. The strings in the child slice retain their order from the parent.

func SliceSubsetsList

func SliceSubsetsList(sLen, strLen int, bias float64) (parent string, child string)

The same as `SliceSubsets`, except the parent and child slices are each joined with "," into strings before being returned.

func StringList

func StringList(sLen, strLen int) string

Same as `StringSlice`, except the slice is joined with "," into a single string at the end.

func StringN

func StringN(n int) string

Generates a pseudo-random string of length `n`.

func StringSlice

func StringSlice(sliceLen, strLen int) (out []string)

Generate a slice containing pseudo-random strings. Params are slice length and string length.

Types

This section is empty.

Jump to

Keyboard shortcuts

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