[Issue 7896] Sequence slicing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 13 02:45:33 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7896



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-04-13 02:46:20 PDT ---
(In reply to comment #0)
> Rather then simply building an array from scratch, perhaps it should be
> possible to do the following:
> 
> auto my_odds = sequence!("n * 2 + 1")()[0...100]
> 
> Unless there is another way to do this.

With range concept, slicing operator with boundaries has no meaning.
You should use std.range.take and std.array.array like follows:

auto my_odds = array(take(sequence!("n * 2 + 1")(), 100));

And if you use 2.059beta or later, you can use UFCS syntax:

auto my_odds = sequence!("n * 2 + 1")().take(100).array();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list