Re: Same process to different results?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 1:44 PM, Steven Schveighoffer wrote: Schizophrenia of Phobos. Phobos thinks a string is a range of dchar instead of a range of char. So what cycle, take, and array all output are dchar ranges and arrays. When you cast the dchar[] result to a string, (which is a char[]), it then

Re: Same process to different results?

2015-07-01 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 01, 2015 at 02:14:49PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/1/15 1:44 PM, Steven Schveighoffer wrote: Schizophrenia of Phobos. Phobos thinks a string is a range of dchar instead of a range of char. So what cycle, take, and array all output are dchar

Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){ int L=25; int seg1len=(L-B.length)/2; int seg2len=B.length;

Re: Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:06:01 UTC, Adam D. Ruppe wrote: I betcha it is because A, B, and C are modified by the first pass. A lot of the range functions consume their input. Running them one at a time produces the same result. for some reason: (A.cycle.take(seg1len).array

Re: Same process to different results?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 1:00 PM, Taylor Hillegeist wrote: When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){ int L=25; int

Re: Same process to different results?

2015-07-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:13:03 UTC, Taylor Hillegeist wrote: string q = cast(string) (A.cycle.take(seg1len).array ~B.cycle.take(seg2len).array ~C.cycle.take(seg3len).array); q.writeln; I was wondering if it might be the cast? Yes, the cast is wrong. You're reinterpreting (not

Re: Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:00:51 UTC, Taylor Hillegeist wrote: When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){