rand

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rand provides functions for generating and dealing with random numbers.

Index

Constants

This section is empty.

Variables

View Source
var Scope = wdte.S().Map(map[wdte.ID]wdte.Func{
	"gen":  wdte.GoFunc(Gen),
	"ugen": wdte.GoFunc(UGen),

	"next":   wdte.GoFunc(Next),
	"stream": wdte.GoFunc(Stream),
})

Scope is a scope containing the functions in this package.

Functions

func Gen

func Gen(frame wdte.Frame, args ...wdte.Func) wdte.Func

Gen is a WDTE function with the following signature:

gen seed

It returns a new Source that starts with the given seed.

func Next

func Next(frame wdte.Frame, args ...wdte.Func) wdte.Func

Next is a WDTE function with the following signature:

next source

It creates and returns the next random number from the given source.

func Stream

func Stream(frame wdte.Frame, args ...wdte.Func) wdte.Func

Stream is a WDTE function with the following signature:

stream source num

It returns a Stream that yields the given number of random numbers from the provided Source.

func UGen

func UGen(frame wdte.Frame, args ...wdte.Func) wdte.Func

UGen is a WDTE function with the following signature:

ugen

It returns a Source that creates numbers from the operating system's cryptographic random number generator.

Types

type Source

type Source interface {
	wdte.Func

	// Next returns the next random number from the generator.
	Next() wdte.Number
}

A Source is a WDTE function that can create successive random numbers.

Jump to

Keyboard shortcuts

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