<br><br><div class="gmail_quote">On Wed, Sep 1, 2010 at 20:54, Peter Neubauer <span dir="ltr">&lt;<a href="mailto:peterneubauer2@gmail.com">peterneubauer2@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br></div>
I&#39;ve encountered a similar problem yesterday. It left me digging through the Phobos docs for an hour looking for an existing solution :-) Let&#39;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&#39;s generate 10 random numbers between 30 and 50. My first attempt was something like this:<br>

</blockquote><div>(snip) <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Oh, and I didn&#39;t test my code at all, apart from those examples. Feel free to use it if you like.<font color="#888888"></font></blockquote>
<div><br>It&#39;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.<br><br><br>Philippe<br> <br></div></div>