How to repeat a function call?
Simen Kjærås
simen.kjaras at gmail.com
Wed Apr 2 14:42:15 PDT 2014
On 2014-04-02 20:48, monarch_dodra wrote:
> On Wednesday, 2 April 2014 at 19:54:38 UTC, monarch_dodra wrote:
>> On Wednesday, 2 April 2014 at 19:02:29 UTC, Simen Kjærås wrote:
>>> Better ideas, please?
>>>
>>> --
>>> Simen
>>
>> I only skimmed through your post, but have you tried taking a look at
>> adjoin? Preferably, the version in head? Something like
>> "adjoin!(repeat!(fun, N))" seems to natively do what you are asking for?
>>
>> I'll re-read your post later tonight, and if I'm misunderstood, I'll
>> try to provide a better solution.
>
> Indeed, "assert(adjoin!(Repeat!(3, ()=>a++))() == tuple(0,1,2));" seems
> to work for me.
>
> That said, while I think the behavior is *defined*, I'm not sure it's
> *specified*.
True, in the case of a++, it's probably a bad idea. In my case, the
function is uniform(0.0, 1.0, rng), and I'm happy with it simply being
random.
Thanks a lot!
--
Simen
More information about the Digitalmars-d-learn
mailing list