Constrained random points on a circle: Difference between revisions

Content added Content deleted
(added ocaml)
No edit summary
Line 153: Line 153:
* * *
* * *
** * </lang>
** * </lang>

=={{header|Liberty BASIC}}==
<lang lb>' RC Constrained Random Points on a Circle

nomainwin

WindowWidth =400
WindowHeight =430

open "Constrained Random Points on a Circle" for graphics_nsb as #w

#w "trapclose [quit]"
#w "down ; size 7 ; color red ; fill black"

for i =1 to 1000
do
x =int( 30 *rnd( 1)) -15
y =int( 30 *rnd( 1)) -15
loop until IsInRange( x, y) =1
#w "set "; 200 +10 *x; " "; 200 - 10 *y
next

wait

function IsInRange( x, y)
z =sqr( x*x +y*y)
if 10 <=z and z <=15 then IsInRange =1 else IsInRange =0
end function

[quit]
close #w
end</lang>


=={{header|MATLAB}}==
=={{header|MATLAB}}==