Problem of Apollonius: Difference between revisions

m
→‎{{header|Perl 6}}: Postfix ² is a built-in these days.
m (→‎{{header|Perl 6}}: Postfix ² is a built-in these days.)
Line 1,938:
This program is written mostly in the "sigilless" style for several reasons. First, sigils tend to imply variables, and these sigilless symbols are not variables, but readonly bindings to values that are calculated only once, so leaving off the sigil emphasizes the fact that they are not variables, but merely named intermediate results.
 
Second, it looks more like the original mathematical formulas to do it this way (which is also why we define a <tt>postfix:<²></tt> for squaring values).
 
Third, together with the use of Unicode, we are emphasizing the social contract between the writer and the reader, which has a clause in it that indicates code is read much more often than it is written, therefore the writer is obligated to undergo vicarious suffering on behalf of the reader to make things clear. If the reader doesn't understand, it's the writer's fault, in other words. Or in other other words, figure out how to type those Unicode characters, even if it's hard. And you should type them whenever it makes things clearer to the reader.
Line 1,952:
 
sub circle($x,$y,$r) { Circle.new: :$x, :$y, :$r }
 
sub postfix:<²>($x) { $x * $x }
 
sub solve-Apollonius([\c1, \c2, \c3], [\s1, \s2, \s3]) {
10,327

edits