streams to ranges adapters

Philippe Sigaud philippe.sigaud at gmail.com
Wed Sep 1 13:13:30 PDT 2010


On Wed, Sep 1, 2010 at 20:54, Peter Neubauer <peterneubauer2 at gmail.com>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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100901/47222141/attachment.html>


More information about the Digitalmars-d-learn mailing list