RosettaCodeData/Task/Constrained-random-points-on-a-circle/Maxima/constrained-random-points-on-a-circle.maxima
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

16 lines
407 B
Text

randomDisc(numPoints):= block([p: []],
local(goodp, random_int),
goodp(x, y):=block([r: sqrt(x^2+y^2)],
r>=10 and r<=15
),
random_int():= block([m: 15], m - random(2*(m+1)-1)),
while length(p)<numPoints do block (
[x: random_int(), y : random_int()],
if goodp(x, y) then (
p: cons([x, y], p)
)
),
p)$
p: randomDisc(100)$
plot2d(['discrete, p], ['style, 'points]);