syphilis has asked for the wisdom of the Perl Monks concerning the following question:
It was explained to me that the PDL module exports its own srand() function - a function that silently clobbers perl's srand() function, and does not seed perl's pseudo-random generator.C:\>perl -MPDL -E "srand(3); say rand();" 0.422170424674736 C:\>perl -MPDL -E "srand(3); say rand();" 0.000277820349769087
Then I placed that file in one of my @INC directories and ran:package OverRider; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(sqrt); our $VERSION = '0.01'; sub sqrt { return sprintf "%.7g", $_[0] ** 0.5; } 1;
Cheers,D:\>perl -Mstrict -Mwarnings -MOverRider -le "print sqrt(2); print COR +E::sqrt(2);" 1.414214 1.4142135623731
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: PDL and srand puzzle
by haj (Vicar) on Jun 04, 2024 at 12:56 UTC | |
Re: PDL and srand puzzle
by hippo (Archbishop) on Jun 04, 2024 at 11:22 UTC | |
Re: PDL and srand puzzle
by etj (Priest) on Jun 04, 2024 at 22:52 UTC | |
by marioroy (Prior) on Jun 04, 2024 at 23:24 UTC | |
by marioroy (Prior) on Jun 04, 2024 at 23:57 UTC | |
by bliako (Abbot) on Jun 04, 2024 at 23:04 UTC | |
by swl (Prior) on Jun 04, 2024 at 23:25 UTC | |
by etj (Priest) on Jun 05, 2024 at 13:30 UTC | |
by marioroy (Prior) on Jun 06, 2024 at 00:30 UTC | |
| |
Re: PDL and srand puzzle
by syphilis (Archbishop) on Jun 05, 2024 at 01:56 UTC | |
by sectokia (Friar) on Jun 05, 2024 at 05:50 UTC | |
by syphilis (Archbishop) on Jun 05, 2024 at 08:10 UTC | |
by sectokia (Friar) on Jun 06, 2024 at 00:40 UTC | |
by syphilis (Archbishop) on Jun 06, 2024 at 02:31 UTC | |
by haj (Vicar) on Jun 05, 2024 at 06:59 UTC | |
by syphilis (Archbishop) on Jun 05, 2024 at 07:49 UTC | |
Re: PDL and srand puzzle
by ikegami (Patriarch) on Jun 05, 2024 at 02:11 UTC |