17 lines
485 B
Text
17 lines
485 B
Text
// Generate points in [min,max]^2 with constraint
|
|
function random_point (min, max, constraint)
|
|
[x, y] = [random(min, max), random(min, max)]
|
|
return constraint(x, y) ? [x, y] : random_point(min, max, constraint)
|
|
end
|
|
|
|
// Generate point list
|
|
in_circle = { x, y => 10**2 <= x**2 + y**2 and x**2 + y**2 <= 15**2 }
|
|
points = [].comp([0:100], {__ => random_point(-15, 15, in_circle)})
|
|
|
|
// Show points
|
|
for i in [-15:16]
|
|
for j in [-15:16]
|
|
>> [i, j] in points ? "x" : " "
|
|
end
|
|
>
|
|
end
|