default random object?
Christopher Wright
dhasenan at gmail.com
Sat Feb 14 09:52:29 PST 2009
Ary Borenszweig wrote:
> Christopher Wright escribió:
>> Andrei Alexandrescu wrote:
>>> auto rng = Random(unpredictableSeed);
>>> auto a = 0.0, b = 1.0;
>>> auto x1 = uniform!("[]")(rng, a, b);
>>> auto x2 = uniform!("[)")(rng, a, b);
>>> auto x3 = uniform!("(]")(rng, a, b);
>>> auto x4 = uniform!("()")(rng, a, b);
>>
>> I always have to look up whether "[]" is exclusive or inclusive. It's
>> succinct, but you only have to write code once, and you have to read
>> it often.
>
> You can remember "]" is more in touch with the number of the right (the
> stick is in full touch with the number) while the ")" only touches the
> number in that tiny right bit of the parenthesis. So the "]" includes
> it, but the ")" merely touches it but doesn't include it.
>
> At least that's what comes to my mind with those symbols. :-P
Right, but these helpful mnemonics will flee well before I see any use
of uniform.
More information about the Digitalmars-d
mailing list