rand_vec

Function rand_vec 

Source
pub fn rand_vec(size: &[usize]) -> Vec<u64>
Expand description

§rand_vec(size)

Generates a vector of pseudo-random u64 numbers based on the specified digit sizes.

The size parameter is a slice of sizes, each representing the number of digits for the corresponding random number to be generated. The function will cap each size at 19 to ensure the generated numbers fit within the limits of u64, preventing overflow.

§Parameters

  • size: A slice containing desired digit counts for each random number. Each value must be greater than 0.

§Returns

A Vec<u64> containing random numbers, each with digit counts specified in the size slice, capped at 19.

§Examples

use mathlab::math::rand_vec;

fn main() {
   // Generating and printing vectors of random numbers with different sizes
   let sizes = vec![1, 2, 3, 6, 15, 19, 25]; // 25 will be capped at 19
   let random_numbers = rand_vec(&sizes);

   for (size, number) in sizes.iter().zip(random_numbers.iter()) {
       println!("Random number (size {}): {:?}", size, number);
   }
}

End Fun Doc