Grabbing a subset of a range if a particular value is found?

Ali Çehreli acehreli at yahoo.com
Tue Sep 24 13:54:29 PDT 2013


On 09/24/2013 01:48 PM, Gary Willoughby wrote:> I'm using 
std.range.recurrence to generate a range but i want to stop it
 > generating and grab the range when a particular value is added. e.g.:
 >
 >      recurrence!("a[n-1] + a[n-2]")(1, 2)
 >      .take(10)
 >      .writeln;
 >
 > This writes ten numbers to the command line which is fair enough but
 > what would be the preferred method to keep building the range until

You said it: until. ;)

   http://dlang.org/phobos/std_algorithm.html#until

 > an
 > element calculated is above a particular value.

Ali



More information about the Digitalmars-d-learn mailing list