Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Pick-random-element/Hare/pick-random-element.hare
Normal file
12
Task/Pick-random-element/Hare/pick-random-element.hare
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use fmt;
|
||||
use math::random;
|
||||
use datetime;
|
||||
|
||||
export fn main() void = {
|
||||
const array = ["one", "two", "three", "four", "five"];
|
||||
const seed = datetime::now();
|
||||
const seed = datetime::nsec(&seed);
|
||||
let r = math::random::init(seed: u32);
|
||||
|
||||
fmt::printfln("{}", array[math::random::u32n(&r, len(array): u32)])!;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue