random

package
v0.0.0-...-a41e324 Latest Latest
Warning

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

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

README

Random Starlark module

Generates and manipulates pseudo-random numbers

Usage

predeclared := starlark.StringDict{
    "random": random.New()
    ...
}
starlark.ExecFile(thread, filename, nil, predeclared)

Supported functions

random.seed()

Initialize the random number generator.

random.randint(a int, b int) int

Return a random integer N such that a <= N <= b for a <= b and b <= N <= a for b < a. Uses Rand.Int63n Go function.

random.random() float

Return the next random floating point number in the range [0.0, 1.0).

random.uniform(a float, b float) float

Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Seed    = rand.Seed
	Float64 = rand.Float64
	Int63n  = rand.Int63n
)

Functions

func New

func New() starlark.Value

Types

type Random

type Random struct{}

func (Random) Methods

func (Random) Methods() map[string]builtin.Function

Jump to

Keyboard shortcuts

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