[Issue 9106] Rename std.random.randomShuffle as std.random.shuffle and small usage change
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 22 10:42:12 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9106
--- Comment #9 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2014-03-22 10:42:07 PDT ---
(In reply to comment #8)
> Initially, I would have been against the renaming. The main argument would be
> that what we have now is consistent as a set of randomization functions
> operating on ranges, and consistent with use in other languages. For example,
> wouldn't it be inconsistent to rename some of the functions (shuffle and
> sample) but not others (randomCover)?
>
> But then, a quick search on modern languages revealed they favor the shorter
> shuffle/sample names. For example, C++ has a legacy random_shuffle but a
> modern C++11 shuffle for use with C++11 RNGs. Python has shuffle and sample.
> Java has shuffle. So, the second part of my argument is no longer valid.
Yup, I'm in the same boat as you: initially resistant but now realizing that
actually it reflects more typical naming practice. So, I'm inclined at least
to switch randomSample => sample (again maintaining an alias for the older
name).
> So, for me, the problem reduced to whether randomCover could use a wholly
> different, better name. So, how is this function called in other languages?
Without any knowledge of how it's addressed in other languages, I would have
been inclined to call it "permute". But I'll look around (you didn't find
anything appropriate in your existing search of Python and C++?)
> By the way, randomCover is terribly inefficient as of DMD 2.065.0 (quadratic in
> total), is that addressed somehow in random2? I have a linear-time approach
> with an associative array in mind, but that would mean reallocating when the AA
> grows, which is something to avoid for Phobos code, right?
Not addressed yet, but something I intend to look into. For this first
iteration the biggest goal was to try and get the API/general design right,
with improved internals the next goal.
I imagine there will be well-defined algorithms in the literature, it's just a
matter of finding said literature, as it's probably in research papers rather
than textbooks.
--
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