Same process to different results?

Taylor Hillegeist via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 1 10:00:48 PDT 2015


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;
   int seg3len=L-seg1len-seg2len;

   (A.cycle.take(seg1len).array
   ~B.cycle.take(seg2len).array
   ~C.cycle.take(seg3len).array).writeln;

   string q = cast(string)
   (A.cycle.take(seg1len).array
   ~B.cycle.take(seg2len).array
   ~C.cycle.take(seg3len).array);

   q.writeln;

}
-----------------------------------------------

I get a weird result of
AaAAaAAaAABbBbCcCcCCcCcCC
A   a   A   A   a   A   A   a   A   A   B   b   B   b   C   c   C 
   c   C   C   c   C   c   C   C

Any ideas why?




More information about the Digitalmars-d-learn mailing list