in reply to Re: Perl disproves commutativity of Addition/Multiplication
in thread Perl disproves commutativity of Addition/Multiplication
anduse warnings; use subs qw(non_commutative); #necessary $x = 10 * non_commutative; $y = non_commutative * 10; print "$x\n$y\n\n"; $x = 10 + non_commutative; $y = non_commutative + 10; print "$x\n$y\n"; sub non_commutative {return 17} __END__ Outputs: 170 17 27 17
Cheers,use warnings; use subs qw(non_commutative); #unnecessary $x = 10 * non_commutative(); $y = non_commutative() * 10; print "$x\n$y\n\n"; $x = 10 + non_commutative(); $y = non_commutative() + 10; print "$x\n$y\n"; sub non_commutative {return 17} __END__ Outputs: 170 170 27 27
|
|---|