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(){
        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?

Some way or another the type was converted to a dchar[]
during this process:

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

Why would it change the type so sneaky like?... Except for maybe its the default behavior with string due to 32bits => (typically one grapheme)?
I bet cycle did this.

Reply via email to