On Saturday, 13 June 2015 at 13:09:20 UTC, Dennis Ritchie wrote:
auto stringB = readln.chomp.map!(to!dchar).array;
auto stringC = readln.chomp.map!(to!dchar).array;
auto charAppender = appender!(dchar[][]);
auto totalStr = stringB.repeat(3).chain(stringC.repeat(5));
charAppender.put(totalStr);
writeln(charAppender);
charAppender.put("c"d.dup);
charAppender.put("test"d.dup);
writeln(charAppender);
Thanks lot that is really good.
One more question I am asking those kind of questions to
understand and not ask same stuff over and over, :
auto totalStr = chain(stringB.replicate(bCount),
stringC.replicate(cCount));
writeln(typeof(totalStr.array()).stringof);
---->dchar[]
But
auto totalStr = chain(stringB.repeat(bCount),
stringC.repeat(cCount));
writeln(typeof(totalStr.array()).stringof);
---->dchar[][]
It seems to me a little inconsistent. range.repeat and
array.replicate gives result in difference dimension.
Is there any explanation or logic that I am missing which results
this behaviour?