Problem of Apollonius: Difference between revisions

m
→‎{{header|Perl}}: all 8 solutions
(Added Perl example)
m (→‎{{header|Perl}}: all 8 solutions)
Line 1,850:
 
=={{header|Perl}}==
Using the module <code>Math::Cartesian::Product</code> to generate the values to allow iteration through all solutions.
{{trans|Perl 6}}
<lang perl>use utf8;
use Math::Cartesian::Product;
 
package Circle;
Line 1,920 ⟶ 1,922:
$c3 = circle(2, 4, 2);
 
for (cartesian {@_} ([-1,1])x3) {
print Circle->show( solve_Apollonius $c1, $c2, $c3, (-1,1)[qw<1 1 1>]);
print Circle->show( solve_Apollonius $c1, $c2, $c3, (-1,1)[qw<0 0 0>]@$_);</lang>
}</lang>
{{out}}
<pre>x = 2.000 y = 20.100833 r = 31.900167
x = 2.000 y = 03.833214 r = 12.167786
x = 3.002 y = 0.123 r = 2.005
</pre>
x = 4.127 y = 3.252 r = 4.255
x = 0.998 y = 0.123 r = 2.005
x = -0.127 y = 3.252 r = 4.255
x = 2.000 y = -1.500 r = 3.500
x = 2.000 y = 2.100 r = 3.900</pre>
 
=={{header|Perl 6}}==
2,392

edits