Simen Kjaeraas wrote: > dsimcha wrote: > >> RangeExtra version 10^-20 is officially out. It consists of a small and >> hopefully growing number of ranges that didn't make it into the new >> Phobos >> that I've gotten working reasonably well and I feel eventually belong >> in Phobos. >> >> Docs / What's there: >> http://cis.jhu.edu/~dsimcha/rangeextra.html >> >> Code: >> http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d >> >> >> License: >> Dual licensed, Phobos license or BSD (Tango style). > > I had hoped reindex would give me access to true 'random' access ranges, > but it seems this does not work: > > auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup ); > > :p
If I had to take a guess, I'd say it was because "uniform" isn't defined in the context of reindex. Maybe this: import std.random; void foo() { auto b = reindex!((i){ return uniform(0,5); })( [0,1,2,3,40.dup ); } I don't think there's any way to get the length. -- Daniel