RosettaCodeData/Task/Exponentiation-order/Julia/exponentiation-order.julia
2023-07-01 13:44:08 -04:00

6 lines
244 B
Text

@show 5 ^ 3 ^ 2 # default: power operator is read right-to-left
@show (5 ^ 3) ^ 2
@show 5 ^ (3 ^ 2)
@show reduce(^, [5, 3, 2])
@show foldl(^, [5, 3, 2]) # guarantees left associativity
@show foldr(^, [5, 3, 2]) # guarantees right associativity