Problem of Apollonius: Difference between revisions
m
→{{header|Perl}}: all 8 solutions
SqrtNegInf (talk | contribs) (Added Perl example) |
SqrtNegInf (talk | contribs) 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,
}</lang>
{{out}}
<pre>x = 2.000 y =
x = 2.000 y =
x = 3.002 y = 0.123 r = 2.005
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}}==
|