Constrained random points on a circle: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
(added perl6) |
||
Line 192: | Line 192: | ||
>> plot(x,y,'.')</lang> |
>> plot(x,y,'.')</lang> |
||
[[File:Matlab-randomDisc-output.png]] |
[[File:Matlab-randomDisc-output.png]] |
||
=={{header|Perl 6}}== |
|||
<lang perl6>my @range = -15..16; |
|||
my @points = gather for @range X @range -> $x, $y { take [$x,$y] if 10 <= sqrt($x*$x+$y*$y) <= 15 }; |
|||
my @samples = @points.pick(100, :replace); # or .pick(100) to get distinct points |
|||
# format and print |
|||
my %matrix; |
|||
for @range X @range -> $x, $y {%matrix{$y}{$x} = ' ' }; |
|||
%matrix{$_[1]}{$_[0]} = '*' for @samples; |
|||
%matrix{$_}{@range}.join('').say for @range;</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |