Why 2 ^^ 1 ^^ 2 = 2?

Ivan Kazmenko gassa at mail.ru
Sun Oct 22 22:28:48 UTC 2017


On Sunday, 22 October 2017 at 14:44:04 UTC, Timon Gehr wrote:
> On 22.10.2017 16:20, Ilya Yaroshenko wrote:
>> .. i thought it should be (2 ^^ 1) ^^ 2 = 4
>
> 2 ^^ (1 ^^ 2) == 2
>
> It is standard for ^/**/^^ to be right-associative. (This is 
> also the standard convention in mathematics.)

Yeah, and a height-3 tower $a^{b^c}$ (TEX notation) actually 
means "a to the power of (b to the power of c)", not the other 
way around.  Otherwise, it can be written as $a^{b \cdot c}$, 
which is only a height-2 tower.

The convention also makes at least the following sense.  An 
expression like
(((a ^^ b) ^^ c) ^^ d) ^^ e
already has an almost bracket-free notation as
a ^^ (b * c * d * e).
So it is useful to have a bracket-free way to write the 
other-way-associative variant,
a ^^ (b ^^ (c ^^ (d ^^ e))).

Ivan Kazmenko.



More information about the Digitalmars-d-learn mailing list