Fugue.Random

Table of Contents

Module Members

randomString

(Function)

Generate a pseudorandom string of the given length.

The supplied generator will determine the generated output characters. When using the default generator (which uses the process FID as a seed) this results in stable String generation from within a process but will generate different Strings upon process creation (since a new FID will be assigned to the process). This is especially useful when global unique naming is required.

Examples:

import Fugue.Random as Random

s3-bucket-name: "thumbnails-" ++ Random.randomString {length: 10}

m: randomString {
  allowedCharacters:"abc123",
  generator: Optional(seedInt(42)),
  length: 10
}

Type Signature

 fun { length: Int,
       allowedCharacters: Optional<String>,
       generator: Optional<RandomGen> } -> String
Argument: length

The length of the result string.

Type: Int

Argument: allowedCharacters

The characters that are allowed in the result string. Defaults to [a-z][0-9].

Type: Optional<String>

Argument: generator

The random number generator. Defaults to seedString(fid).

Type: Optional<RandomGen>

Returns:

The pseudorandom string of the given length.

Type: String