On Thursday, 20 March 2014 at 22:46:53 UTC, Ali Çehreli wrote:
On 03/20/2014 03:03 PM, Brad Anderson wrote:

> I'm not entirely happy with it but:

I am not happy with my attempt either. :)

>    void main()
>    {
>      import std.algorithm, std.range, std.stdio, std.conv;
>
>      enum length = 5;
>      auto rng =
>         chain(iota(length), iota(length, -1, -1))

Ooh. I like that. That would have never occurred to me. :)

It felt kind of clumsy when I ended up with it. I don't think it shows my intent very well (repeat the range in reverse). I wish Phobos had something like a mirror() range (i.e. chain(rng, rng.retro())).


>        .map!((a => " ".repeat(length-a)),
>              (a => "#".repeat(a*2+1)))
>        .map!(a => chain(a[0].joiner, a[1].joiner, "\n"))
>        .joiner;
>
>      writeln(rng);
>    }

Does that compile for you? Failed for me with v2.066-devel-d0f461a:
[snip]
A regression?



I did it on dpaste which is using 2.065 so I suspect regression.

http://dpaste.dzfl.pl/71c331960cb0


> Had some trouble with the result coming out as integers
instead of
> something string-like.

I had the same problem at one point. I will try to understand when that happens.

Ali

I was getting the integers when I was using character literals with repeat() rather than string literals.

Reply via email to