digitalmars.D - std.array string.split("") bug
- Borislav Kosharov (15/15) Aug 07 2013 Something strange happens when I do this:
- John Colvin (5/20) Aug 07 2013 It's a bug in std.algorithm.splitter
- H. S. Teoh (6/30) Aug 07 2013 Not only so, .front doesn't return the first character either. I'm
- H. S. Teoh (7/35) Aug 07 2013 [...]
- Andre Artus (8/23) Aug 08 2013 There is probably a better way to do it, but I'm still mostly
- Tyler Jameson Little (3/18) Aug 08 2013 Bugs go here: http://d.puremagic.com/issues/
- H. S. Teoh (7/24) Aug 07 2013 Looks like a bug with split(); it doesn't terminate when the delimiter
- H. S. Teoh (7/30) Aug 07 2013 [...]
Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?
Aug 07 2013
On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov wrote:Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?It's a bug in std.algorithm.splitter popFront doesn't actually pop anything at all when the separator is a "", so it just keeps iterating forever.
Aug 07 2013
On Wed, Aug 07, 2013 at 10:39:11PM +0200, John Colvin wrote:On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov wrote:Not only so, .front doesn't return the first character either. I'm looking into the code to see if I can fix it... T -- The two rules of success: 1. Don't tell everything you know. -- YHLSomething strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?It's a bug in std.algorithm.splitter popFront doesn't actually pop anything at all when the separator is a "", so it just keeps iterating forever.
Aug 07 2013
On Wed, Aug 07, 2013 at 01:42:13PM -0700, H. S. Teoh wrote:On Wed, Aug 07, 2013 at 10:39:11PM +0200, John Colvin wrote:[...] Fixed: https://github.com/D-Programming-Language/phobos/pull/1456 T -- Being able to learn is a great learning; being able to unlearn is a greater learning.On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov wrote:Not only so, .front doesn't return the first character either. I'm looking into the code to see if I can fix it...Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?It's a bug in std.algorithm.splitter popFront doesn't actually pop anything at all when the separator is a "", so it just keeps iterating forever.
Aug 07 2013
On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov wrote:Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?There is probably a better way to do it, but I'm still mostly ignorant about D. auto test = "test".map!(a=>to!(string)(a)).join("-"); I would like to be able to write `"test".join('-')` to get the same result, after all one wants to intercalate a [repetition of] char into an array of chars, but that does not currently work.
Aug 08 2013
On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov wrote:Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?Bugs go here: http://d.puremagic.com/issues/
Aug 08 2013
On Wed, Aug 07, 2013 at 09:10:04PM +0200, Borislav Kosharov wrote:Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?Looks like a bug with split(); it doesn't terminate when the delimiter is an empty string. Please report a bug here: http://d.puremagic.com/issues/ T -- "The number you have dialed is imaginary. Please rotate your phone 90 degrees and try again."
Aug 07 2013
On Wed, Aug 07, 2013 at 12:44:54PM -0700, H. S. Teoh wrote:On Wed, Aug 07, 2013 at 09:10:04PM +0200, Borislav Kosharov wrote:[...] Actually, don't worry about that, I've just filed the bug myself: http://d.puremagic.com/issues/show_bug.cgi?id=10773 T -- All problems are easy in retrospect.Something strange happens when I do this: unittest { import std.array, std.string; string s = "test"; //assert(s.toUpper.split("").join("-") == "T-E-S-T"); //"Memory allocation failed" //[Finished in 26.5s] //CPU: 1% -> 50% | 2.7GHz dual core //RAM: 1.6GB -> 2.6GB | 1GB diff assert(s.split("") == ["t","e","s","t"]); //ditto } I just want to achieve what the commented assert's result should be. Is there a better way to do that? And if it is really a bug where should I report it?Looks like a bug with split(); it doesn't terminate when the delimiter is an empty string. Please report a bug here: http://d.puremagic.com/issues/
Aug 07 2013