On Wed, Sep 1, 2010 at 20:54, Peter Neubauer <[email protected]>wrote:

>
> I've encountered a similar problem yesterday. It left me digging through
> the Phobos docs for an hour looking for an existing solution :-) Let's say I
> have a function (or any D expression,) and I want to turn consecutive calls
> to this function into range form. As an example, let's generate 10 random
> numbers between 30 and 50. My first attempt was something like this:
>
(snip)

> Oh, and I didn't test my code at all, apart from those examples. Feel free
> to use it if you like.


It's a good idea and a common need: to transform a generator into a range.
It could be adapted to work with callable structs and classes, too, if you
need it to hold state.


Philippe

Reply via email to