Exponentiation with infix operators in (or operating on) the base: Difference between revisions

Content added Content deleted
(added AWK)
m (→‎{{header|R}}: Syntax highlighting.)
Line 461: Line 461:
</pre>
</pre>
=={{header|R}}==
=={{header|R}}==
<lang R>expressions <- alist(-x ^ p, -(x) ^ p, (-x) ^ p, -(x ^ p))
<lang rsplus>expressions <- alist(-x ^ p, -(x) ^ p, (-x) ^ p, -(x ^ p))
x <- c(-5, -5, 5, 5)
x <- c(-5, -5, 5, 5)
p <- c(2, 3, 2, 3)
p <- c(2, 3, 2, 3)
Line 475: Line 475:
5 2 -25 -25 25 -25
5 2 -25 -25 25 -25
5 3 -125 -125 -125 -125</pre>
5 3 -125 -125 -125 -125</pre>

=={{header|Raku}}==
=={{header|Raku}}==
In Raku by default, infix exponentiation binds tighter than unary negation. It is trivial however to define your own infix operators with whatever precedence level meets the needs of your program.
In Raku by default, infix exponentiation binds tighter than unary negation. It is trivial however to define your own infix operators with whatever precedence level meets the needs of your program.