Constrained random points on a circle: Difference between revisions

Content added Content deleted
(CoffeeScript)
(Updated D entry)
Line 479: Line 479:


=={{header|D}}==
=={{header|D}}==
This uses std.complex because D built-in complex numbers will be deprecated.
<lang d>import std.stdio, std.random, std.math;
<lang d>import std.stdio, std.random, std.math, std.complex;


void main() {
void main() {
Line 489: Line 490:
x = uniform(-15, 16);
x = uniform(-15, 16);
y = uniform(-15, 16);
y = uniform(-15, 16);
} while(abs(12.5 - abs(x + y * 1i)) > 2.5);
} while(abs(12.5 - complex(x, y).abs) > 2.5);
table[x + 15][y + 15] = '*';
table[x + 15][y + 15] = '*';
}
}