Function to print a diamond shape

Jay Norwood via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 23 05:20:44 PDT 2014


On Tuesday, 22 April 2014 at 15:25:04 UTC, monarch_dodra wrote:
> Yeah, that's because join actually works on "RoR, R", rather 
> than "R, E". This means if you feed it a "string[], string", 
> then it will actually iterate over individual *characters*. Not 
> only that, but since you are using char[], it will decode them 
> too.
>
> "join" is faster for 2 reasons:
> 1) It detects you want to joins arrays, so it doesn't have to 
> iterate over them: It just glues them "slice at once"
> 2) No UTF decoding.
>
> I kind of wish we had a faster joiner, but I think it would 
> have made the call ambiguous.

Ok, thanks.  I re-tried joiner with both parameters being ranges, 
but there was no improvement in execution speed.  I thought 
perhaps from your comments that it might work.

     char nl[] = uninitializedArray!(char[])(1);
     nl[] = '\n';

     write(joiner(wc,nl));


More information about the Digitalmars-d-learn mailing list