RosettaCodeData/Task/Constrained-random-points-on-a-circle/Zkl/constrained-random-points-on-a-circle.zkl
2017-09-25 22:28:19 +02:00

10 lines
415 B
Text

xy:=(0).walker(*).tweak(fcn{ // generate infinite random pairs (lazy)
x:=(-15).random(16); y:=(-15).random(16);
if(not (100<=(x*x + y*y)<=225)) Void.Skip else T(x,y)
});
const N=31; // [-15..15] includes 0
array:=(" ,"*N*N).split(",").copy(); // bunch of spaces (list)
xy.walk(100).apply2(fcn([(x,y)],array){array[x+15 + N*(y+15)]="*"},array);
foreach n in ([0..30]){ array[n*N,30].concat().println(); }