Creating a custom iota()

realhet real_het at hotmail.com
Thu May 12 21:42:23 UTC 2022


On Thursday, 12 May 2022 at 20:12:19 UTC, Ali Çehreli wrote:
> And I've been thinking 'iota' may not be as suitable as I 
> thought at first. I like the following even more:
>
>   auto r0 = st
>             .by(Duration(2))
>             .take(5);

So I wrote this by() for my DateTime and then:

     import quantities.si;

     auto by(in DateTime begin, in Frequency f){
       return begin.by(1/f);
     }

     //This let me do:

     now.by(60*hertz)
        .until!"a>b"(now+1*second)
        .each!writeln;

My mind is blowing! :D



More information about the Digitalmars-d-learn mailing list