rsFalse has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to set fixed hash behavior: getting the same order of keys (or values, or each)?
1. For every same hash in running script.
2. For every same hash between running script several times.
How scripts, output of which depend on hashes, are tested? E.g. once generated desired output, which is suitable for being a test case, won't be the same in the next run?
Comparing to scripts which uses 'rand' one can set the same seed ('srand CONST') for getting the same output every time.
Upd. E.g. I shuffled (10k times) an array with a hash, and got different patterns of shuffling occurrences between different script runs (see from here: Re: RFC: Kinda pseudo-shuffle using sort).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Is it possible to "fix a seed" for hash?
by choroba (Cardinal) on Mar 16, 2021 at 13:01 UTC | |
by rsFalse (Chaplain) on Mar 22, 2021 at 10:13 UTC | |
by haukex (Archbishop) on Mar 22, 2021 at 22:16 UTC | |
by choroba (Cardinal) on Mar 22, 2021 at 10:18 UTC | |
Re: Is it possible to "fix a seed" for hash?
by haukex (Archbishop) on Mar 16, 2021 at 14:57 UTC | |
Re: Is it possible to "fix a seed" for hash?
by Anonymous Monk on Mar 16, 2021 at 13:02 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |