Anonymous user
Yin and yang: Difference between revisions
Simplified D code
Underscore (talk | contribs) (→{{header|SVG}}: Added a rendering.) |
(Simplified D code) |
||
Line 5:
=={{header|D}}==
<lang d>import std.stdio, std.string, std.algorithm, std.array;▼
▲<lang d>import std.stdio, std.string, std.algorithm ;
struct SquareBoard {
enum W : char { Void
▲ immutable int size ;
▲ int[][] pix ;
▲ this(int s) {
string toString() {
scale = s ;▼
auto rows = map!q{ (cast(char[])a).idup }(pix);
return join(array(rows), "\n");
▲ pix = new int[][](size + 1,size + 1) ;
alias pix this ;▼
foreach (y, ref r; pix)
if (dx ^^ 2
}
▲ void drawCircle(int cx, int cy, int cr, Draw action) {
foreach
r[] =
drawCircle(6, 6, 6,
(int
drawCircle(6, 3, 3,
drawCircle(6, 9, 1, (int x){ return
▲ }
}
▲ Board yanYin() {
▲ drawCircle(6,9,3, (int x) { return Yin ; } ) ;
▲ drawCircle(6,3,1, (int x) { return Yin ; } ) ;
▲ }
}
void main(
}</lang>
Output:
|