[Issue 9106] Rename std.random.randomShuffle as std.random.shuffle and small usage change
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 8 11:30:45 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=9106
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Rename |Rename
|std.random.randomShuffle as |std.random.randomShuffle as
|std.random.shuffle |std.random.shuffle and
| |small usage change
--- Comment #4 from bearophile_hugs at eml.cc 2013-11-08 11:30:41 PST ---
Along with the name change it could be a good idea to also change the API a
little.
I'd like std.random.shuffle to be usable UFCS chains. Currently you can't:
void main() {
import std.stdio, std.random, std.algorithm, std.array;
auto data = [10, 20, 30];
auto pairs = cartesianProduct(data, data).array;
pairs.randomShuffle;
pairs.writeln;
}
A possible usage in a UFCS chain:
void main() {
import std.stdio, std.random, std.algorithm, std.array;
auto data = [10, 20, 30];
cartesianProduct(data, data)
.array
.shuffle
.writeln;
}
An alternative way, more similar to std.algorithm.sort, this helps remember
that shuffe works in-place:
void main() {
import std.stdio, std.random, std.algorithm, std.array;
auto data = [10, 20, 30];
cartesianProduct(data, data)
.array
.shuffle
.release
.writeln;
}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list