in reply to Make random numbers
Here's one example:
use warnings; use strict; use Inline 'C'; my @random_numbers = getRand(1, 1000, 100); print "$_\n" for @random_numbers; __END__ __C__ #include <stdlib.h> void getRand (int start, int end, int iterations){ time_t t; srand((unsigned) time(&t)); inline_stack_vars; inline_stack_reset; int i; for (i = 0; i < iterations; i++){ int randomNum = rand() % (end - start); inline_stack_push(sv_2mortal(newSViv(randomNum))); } inline_stack_done; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Make random numbers
by Tux (Canon) on Dec 07, 2018 at 07:29 UTC | |
by stevieb (Canon) on Dec 07, 2018 at 15:46 UTC |