www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5508] New: Update startsWith to take a range of ranges

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

           Summary: Update startsWith to take a range of ranges
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: andrei metalanguage.com
        ReportedBy: Jesse.K.Phillips+D gmail.com
                CC: Jesse.K.Phillips+D gmail.com



11:28:48 PST ---
Currently std.algorithm.startsWith accepts any number of ranges. It would be
nice if this case below could pass:

import std.algorithm;

void main() {
    auto a = ["\r\nHello"];
    assert(startsWith(a, ["\n","\r\n"], ["H"]));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com
           Platform|Other                       |All
         OS/Version|Linux                       |All
           Severity|normal                      |enhancement


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




PST ---
Not sure I get the semantics. Currently the assertion fails because the first
array does not start with any of the other arrays. Please advise.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508




08:02:11 PST ---

 Not sure I get the semantics. Currently the assertion fails because the first
 array does not start with any of the other arrays. Please advise.
The array starts with \r\n which is the second element in the second array. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID



PST ---


 Not sure I get the semantics. Currently the assertion fails because the first
 array does not start with any of the other arrays. Please advise.
The array starts with \r\n which is the second element in the second array.
I understand. But that conflicts with the current semantics, which say that for x and y of type T[], x.startsWith(y) is true iff y is a prefix of x. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508




16:24:24 PST ---

 I understand. But that conflicts with the current semantics, which say that for
 x and y of type T[], x.startsWith(y) is true iff y is a prefix of x.
But Y is of type Range!(T[]). I guess it is to boyerMooreFinder[1] as startsWith is to find. 1. http://dlang.org/phobos/std_algorithm.html#boyerMooreFinder -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508




PST ---


 I understand. But that conflicts with the current semantics, which say that for
 x and y of type T[], x.startsWith(y) is true iff y is a prefix of x.
But Y is of type Range!(T[]).
No, look again at your example. All ranges have type string[]. Did you actually mean this? import std.algorithm; void main() { auto a = "\r\nHello"; assert(startsWith(a, ["\n","\r\n"], ["H"])); } Note that now a is of type string. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5508




17:52:39 PST ---

 No, look again at your example. All ranges have type string[]. Did you actually
 mean this?
 
 import std.algorithm;
 
 void main() {
     auto a = "\r\nHello";
     assert(startsWith(a, ["\n","\r\n"], ["H"]));
 }
 
 Note that now a is of type string.
It has been awhile since I wrote this, but I'm at least currently interested in what you have written. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013