How to repeat a function call?

monarch_dodra monarchdodra at gmail.com
Wed Apr 2 13:48:43 PDT 2014


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*.


More information about the Digitalmars-d-learn mailing list