vendredi 29 janvier 2016

How do I get a randomly selected hash key in Perl 6?

A quick and hopefully easy question;

I need the means to select from among a given set of hash keys at random. I'll keep poking after this post, but the perl6.org documentation on neither rand nor hash offer many hints.

my %a = 1,2,3,4,5,6;

Given the above,

%a.keys;

returns (5 1 3)... and if I simply try

%a.rand;

however, I get pseudorandom float rather than any one key.




Aucun commentaire:

Enregistrer un commentaire