LDC 0.12.0 has been released

bearophile bearophileHUGS at lycos.com
Wed Oct 23 11:43:47 PDT 2013


> A small test program:
>
>
> void main() {
>     import core.stdc.stdio, std.math;
>     immutable r = 11;
>     foreach (immutable y; -r .. r + 1) {
>         foreach (immutable x; -2 * r .. 2 * r + 1) {
>             bool circle(in int c, in int r) pure nothrow {
>                 return r ^^ 2 >= (x / 2) ^^ 2 + (y - c) ^^ 2;
>             }
>             putchar(circle(-r / 2, r / 6) ? '#' :
>                     circle( r / 2, r / 6) ? '.' :
>                     circle(-r / 2, r / 2) ? '.' :
>                     circle( r / 2, r / 2) ? '#' :
>                     circle(     0, r)     ? "#."[x < 0] :
>                                           ' ');
>         }
>         '\n'.putchar;
>     }
> }


Sorry, I have copied two times the same code. That first code 
should be:

void main() {
     import core.stdc.stdio, std.math;
     immutable r = 11;
     foreach (immutable y; -r .. r + 1) {
         foreach (immutable x; -2 * r .. 2 * r + 1) {
             enum circle = (in int c, in int r) pure nothrow =>
                 r ^^ 2 >= (x / 2) ^^ 2 + (y - c) ^^ 2;
             putchar(circle(-r / 2, r / 6) ? '#' :
                     circle( r / 2, r / 6) ? '.' :
                     circle(-r / 2, r / 2) ? '.' :
                     circle( r / 2, r / 2) ? '#' :
                     circle(     0, r)     ? "#."[x < 0] :
                                           ' ');
         }
         '\n'.putchar;
     }
}


Bye,
bearophile


More information about the digitalmars-d-ldc mailing list