lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
// Generated by Lisette bindgen
// Source: math/rand (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

/// ExpFloat64 returns an exponentially distributed float64 in the range
/// (0, +[math.MaxFloat64]] with an exponential distribution whose rate parameter
/// (lambda) is 1 and whose mean is 1/lambda (1) from the default [Source].
/// To produce a distribution with a different rate parameter,
/// callers can adjust the output using:
/// 
/// 	sample = ExpFloat64() / desiredRateParameter
pub fn ExpFloat64() -> float64

/// Float32 returns, as a float32, a pseudo-random number in the half-open interval [0.0,1.0)
/// from the default [Source].
pub fn Float32() -> float32

/// Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0)
/// from the default [Source].
pub fn Float64() -> float64

/// Int returns a non-negative pseudo-random int from the default [Source].
pub fn Int() -> int

/// Int31 returns a non-negative pseudo-random 31-bit integer as an int32
/// from the default [Source].
pub fn Int31() -> int32

/// Int31n returns, as an int32, a non-negative pseudo-random number in the half-open interval [0,n)
/// from the default [Source].
/// It panics if n <= 0.
pub fn Int31n(n: int32) -> int32

/// Int63 returns a non-negative pseudo-random 63-bit integer as an int64
/// from the default [Source].
pub fn Int63() -> int64

/// Int63n returns, as an int64, a non-negative pseudo-random number in the half-open interval [0,n)
/// from the default [Source].
/// It panics if n <= 0.
pub fn Int63n(n: int64) -> int64

/// Intn returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n)
/// from the default [Source].
/// It panics if n <= 0.
pub fn Intn(n: int) -> int

pub fn New(src: Source) -> Ref<Rand>

pub fn NewSource(seed: int64) -> Source

pub fn NewZipf(r: Ref<Rand>, s: float64, v: float64, imax: uint64) -> Option<Ref<Zipf>>

/// NormFloat64 returns a normally distributed float64 in the range
/// [-[math.MaxFloat64], +[math.MaxFloat64]] with
/// standard normal distribution (mean = 0, stddev = 1)
/// from the default [Source].
/// To produce a different normal distribution, callers can
/// adjust the output using:
/// 
/// 	sample = NormFloat64() * desiredStdDev + desiredMean
pub fn NormFloat64() -> float64

/// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers
/// in the half-open interval [0,n) from the default [Source].
pub fn Perm(n: int) -> Slice<int>

/// Read generates len(p) random bytes from the default [Source] and
/// writes them into p. It always returns len(p) and a nil error.
/// Read, unlike the [Rand.Read] method, is safe for concurrent use.
/// 
/// Deprecated: For almost all use cases, [crypto/rand.Read] is more appropriate.
/// If a deterministic source is required, use [math/rand/v2.ChaCha8.Read].
pub fn Read(mut p: Slice<uint8>) -> Result<int, error>

/// Seed uses the provided seed value to initialize the default Source to a
/// deterministic state. Seed values that have the same remainder when
/// divided by 2³¹-1 generate the same pseudo-random sequence.
/// Seed, unlike the [Rand.Seed] method, is safe for concurrent use.
/// 
/// If Seed is not called, the generator is seeded randomly at program startup.
/// 
/// Prior to Go 1.20, the generator was seeded like Seed(1) at program startup.
/// To force the old behavior, call Seed(1) at program startup.
/// Alternately, set GODEBUG=randautoseed=0 in the environment
/// before making any calls to functions in this package.
/// 
/// Deprecated: As of Go 1.20 there is no reason to call Seed with
/// a random value. Programs that call Seed with a known value to get
/// a specific sequence of results should use New(NewSource(seed)) to
/// obtain a local random generator.
/// 
/// As of Go 1.24 [Seed] is a no-op. To restore the previous behavior set
/// GODEBUG=randseednop=0.
pub fn Seed(seed: int64)

/// Shuffle pseudo-randomizes the order of elements using the default [Source].
/// n is the number of elements. Shuffle panics if n < 0.
/// swap swaps the elements with indexes i and j.
pub fn Shuffle(n: int, swap: fn(int, int) -> ())

/// Uint32 returns a pseudo-random 32-bit value as a uint32
/// from the default [Source].
pub fn Uint32() -> uint32

/// Uint64 returns a pseudo-random 64-bit value as a uint64
/// from the default [Source].
pub fn Uint64() -> uint64

/// A Rand is a source of random numbers.
pub type Rand

/// A Source represents a source of uniformly-distributed
/// pseudo-random int64 values in the range [0, 1<<63).
/// 
/// A Source is not safe for concurrent use by multiple goroutines.
pub interface Source {
  fn Int63() -> int64
  fn Seed(seed: int64)
}

/// A Source64 is a [Source] that can also generate
/// uniformly-distributed pseudo-random uint64 values in
/// the range [0, 1<<64) directly.
/// If a [Rand] r's underlying [Source] s implements Source64,
/// then r.Uint64 returns the result of one call to s.Uint64
/// instead of making two calls to s.Int63.
pub interface Source64 {
  fn Int63() -> int64
  fn Seed(seed: int64)
  fn Uint64() -> uint64
}

/// A Zipf generates Zipf distributed variates.
pub type Zipf

impl Rand {
  /// ExpFloat64 returns an exponentially distributed float64 in the range
  /// (0, +[math.MaxFloat64]] with an exponential distribution whose rate parameter
  /// (lambda) is 1 and whose mean is 1/lambda (1).
  /// To produce a distribution with a different rate parameter,
  /// callers can adjust the output using:
  /// 
  /// 	sample = ExpFloat64() / desiredRateParameter
  fn ExpFloat64(self: Ref<Rand>) -> float64

  /// Float32 returns, as a float32, a pseudo-random number in the half-open interval [0.0,1.0).
  fn Float32(self: Ref<Rand>) -> float32

  /// Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).
  fn Float64(self: Ref<Rand>) -> float64

  /// Int returns a non-negative pseudo-random int.
  fn Int(self: Ref<Rand>) -> int

  /// Int31 returns a non-negative pseudo-random 31-bit integer as an int32.
  fn Int31(self: Ref<Rand>) -> int32

  /// Int31n returns, as an int32, a non-negative pseudo-random number in the half-open interval [0,n).
  /// It panics if n <= 0.
  fn Int31n(self: Ref<Rand>, n: int32) -> int32

  /// Int63 returns a non-negative pseudo-random 63-bit integer as an int64.
  fn Int63(self: Ref<Rand>) -> int64

  /// Int63n returns, as an int64, a non-negative pseudo-random number in the half-open interval [0,n).
  /// It panics if n <= 0.
  fn Int63n(self: Ref<Rand>, n: int64) -> int64

  /// Intn returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n).
  /// It panics if n <= 0.
  fn Intn(self: Ref<Rand>, n: int) -> int

  /// NormFloat64 returns a normally distributed float64 in
  /// the range -[math.MaxFloat64] through +[math.MaxFloat64] inclusive,
  /// with standard normal distribution (mean = 0, stddev = 1).
  /// To produce a different normal distribution, callers can
  /// adjust the output using:
  /// 
  /// 	sample = NormFloat64() * desiredStdDev + desiredMean
  fn NormFloat64(self: Ref<Rand>) -> float64

  /// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers
  /// in the half-open interval [0,n).
  fn Perm(self: Ref<Rand>, n: int) -> Slice<int>

  /// Read generates len(p) random bytes and writes them into p. It
  /// always returns len(p) and a nil error.
  /// Read should not be called concurrently with any other Rand method.
  fn Read(self: Ref<Rand>, mut p: Slice<uint8>) -> Partial<int, error>

  /// Seed uses the provided seed value to initialize the generator to a deterministic state.
  /// Seed should not be called concurrently with any other [Rand] method.
  fn Seed(self: Ref<Rand>, seed: int64)

  /// Shuffle pseudo-randomizes the order of elements.
  /// n is the number of elements. Shuffle panics if n < 0.
  /// swap swaps the elements with indexes i and j.
  fn Shuffle(self: Ref<Rand>, n: int, swap: fn(int, int) -> ())

  /// Uint32 returns a pseudo-random 32-bit value as a uint32.
  fn Uint32(self: Ref<Rand>) -> uint32

  /// Uint64 returns a pseudo-random 64-bit value as a uint64.
  fn Uint64(self: Ref<Rand>) -> uint64
}

impl Zipf {
  /// Uint64 returns a value drawn from the [Zipf] distribution described
  /// by the [Zipf] object.
  fn Uint64(self: Ref<Zipf>) -> uint64
}