Constrained random points on a circle: Difference between revisions

→‎{{header|Maxima}}: add a solution
No edit summary
(→‎{{header|Maxima}}: add a solution)
Line 1,428:
[[File:Matlab-randomDisc-output.png]]
 
=={{header|Maxima}}==
<lang Maxima>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]);</lang>
 
=={{header|OCaml}}==