www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7896] New: Sequence slicing

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896

           Summary: Sequence slicing
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: daniel350 bigpond.com



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com



02:33:47 PDT ---
Somehow take(sequence!("n * 2 + 1")(), 100) doesn't cut it or what?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896





 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: -------
Apr 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc




 With range concept, slicing operator with boundaries has no meaning.
I think the point of this enhancement request is to give a meaning to that syntax. So: someRange[x .. y] becomes syntax sugar for calling a function like: itertools.islice(someRange, x, y) of Python: http://docs.python.org/library/itertools.html#itertools.islice the idea of giving some more syntax support to D lazy ranges isn't that bad. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896




04:37:09 PDT ---
The syntax is supported. It's just up to implementer of a range if he can
provide opSlice meaningfully.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896




PDT ---
Made a pull request for this:
https://github.com/D-Programming-Language/phobos/pull/748

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/d9e1a501ecba84426ddde161dce7408e719a1a8b
Added std.range.Sequence slicing (Issue 7896)

See http://d.puremagic.com/issues/show_bug.cgi?id=7896 for more information.

https://github.com/D-Programming-Language/phobos/commit/1b645ba717aadf175b93ab344394284008ff5d7d


Added std.range.Sequence slicing (Issue 7896)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7896


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


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