Don wrote:
bearophile wrote:
KennyTM~:
But the mathematical convention is a^b^c == a^(b^c).
Languages which the power operator is right-associative (3^3^3==7e12):
- Python, Haskell, Ruby, Perl, Mathematica, Bash.
Doing things as in mathematical convention, Mathematica and Python
sounds better.
This was just the release V.0.1 of the built-in pow, it needs several
improvements :-)
Bye,
bearophile
Fortran too.
Here's a link from the TCL language, with a nice explanation of the
rationale for choosing right associativity.
http://www.tcl.tk/cgi-bin/tct/tip/274.html
Don I thought you were the one who created the patch
http://d.puremagic.com/issues/show_bug.cgi?id=3481
What was your reason for the choice of left associativity? To cite
wikipedia:
http://en.wikipedia.org/wiki/Associativity#Notation_for_non-associative_operations
"x^{y^z}=x^{(y^z)}.\,
The reason exponentiation is right-associative is that a repeated
left-associative exponentiation operation would be less useful. Multiple
appearances could (and would) be rewritten with multiplication:
(x^y)^z=x^{(yz)}.\,"