Pudu programming language
Menu
API reference

Std.Random.below

1 declaration

fn

below: &Std.Random.Generator -> N -> (Std.Random.Generator, N) where N: Integer

This is a callable function.

What it does

A number below a bound, and the generator that follows.

The bound's own type is the answer's type: a caller drawing indices for a

UInt8 array gets a UInt8 back and never leaves its width. The bound is

the type witness, which is what lets one function serve the whole integer

family without a conversion the caller has to undo.

A bound of nought or less answers nought, because there is no number below

it and refusing would make every caller handle a case they can see is

impossible.

Read the signature

  • The text after the name is the type checked by Pudu.
  • Read arrows from left to right: inputs come first, and the final type is returned.
  • & borrows a value for this call instead of moving or copying it.

Back to Std.RandomSearch related declarations