Squeak Smalltak, Does +, -, *, / have more priority over power?

I understand in Smalltalk numerical calculation, if without parentheses, everything starts to be calculated from left to right. Nothing follows the rule of multiplication and division, which has more priority over addition and subtraction.

Like the following codes

3 + 3 * 2

The print output is 12, and in mathematics we get 9


But when I started checking power, for example

91 raisedTo: 3 + 1. 

I thought the answer should be 753572

I really get 68574964

What for?

Is it because they +, -, *, /have more priority over power?

+4
source share
2 answers

, +, -, *, / , raisedTo:, , .

Smalltalk : , . +, -, * / , raisedTo: . , , , , . , , , . , raisedTo: - , ( ).

, 91 raisedTo: 3 + 1 , (+) (raisedTo:), :

, , , ,

3 + 1 . , , . :

(91 raisedTo: 3) + 1

raisedTo:, +. ,

91 raisedTo: (3 + 1)

. , Smalltalk , .


@ Point x @ y

>= ..

-> Association key -> value

==> , PetitParser

=

== ( )

~=

~~

\\

// quotient

. , .

+6

Smalltalk . . .

:

  • , squared asString 3 squared order asString;
  • , , !%&*+,/<=>?@\~- + -> 3 + 4 key -> value;
  • , raisedTo: to:by:do: 4 risedTo: 3 1 to: 10 by: 3 do: [ … ].

, . :

unary > binary > keyword

,

5 raisedTo: 7 - 2 squared = 125

2 squared 4, 7 - 4, 3, , , 5 risedTo: 3 125.

, .

, , - , - . , a + b * c , a, b c . , , -. + *, , * ( "", " " ) +.

+6

Source: https://habr.com/ru/post/1689134/


All Articles