develooper Front page | perl.perl6.language | Postings from February 2005

Re: Pick's randomness (was Re: Fun with junctions (was Sets vs Junctions))

Thread Previous | Thread Next
From:
David Storrs
Date:
February 14, 2005 07:30
Subject:
Re: Pick's randomness (was Re: Fun with junctions (was Sets vs Junctions))
Message ID:
20050213235411.GK19489@megazone.bigpanda.com
On Mon, Feb 14, 2005 at 10:43:21AM +1100, Damian Conway wrote:
> David Storrs OOC'd:
> 
> >OOC, will there be a way to control where C<pick> gets its randomness
> >from?  (e.g. perl's builtin PRNG, /dev/random, egd, etc)
> 
> Sure:
> 
>     # Use RBR (Really Bad Randomness) algorithm...
>     temp *rand (Num ?$max = 1) {
>         return $max/2;
>     }
> 
>     my $guess = @data.pick;

Ok, so it requires actually overriding the rand function and providing
your own implementation.  I was hoping for something a bit more
automagical (probably involving a property or role, since they seem to
be the answer to everything these days), but this will work fine.

--Dks

-- 
dstorrs@dstorrs.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About