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


--- Comment #0 from Daniel <daniel350 bigpond.com> 2012-04-13 02:06:23 PDT ---
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


--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-04-13
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



--- Comment #2 from Kenji Hara <k.hara.pg 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: -------
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


--- Comment #3 from bearophile_hugs eml.cc 2012-04-13 04:21:59 PDT ---
(In reply to comment #2)
 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



--- Comment #4 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-04-13
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



--- Comment #5 from Daniel Cousens <daniel350 bigpond.com> 2012-08-12 05:50:52
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



--- Comment #6 from github-bugzilla puremagic.com 2012-09-16 19:17:33 PDT ---
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
Merge pull request #748 from RommelVR/master

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