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

Content deleted Content added
Blek (talk | contribs)
Haskell added
Blek (talk | contribs)
Put all power functions in Haskell
Line 257: Line 257:
main = do
main = do
print [-5^2,-(5)^2,(-5)^2,-(5^2)] --Integer
print [-5^2,-(5)^2,(-5)^2,-(5^2)] --Integer
print [-5^^2,-(5)^^2,(-5)^^2,-(5^^2)] --Fractional
print [-5**2,-(5)**2,(-5)**2,-(5**2)] --Real
print [-5**2,-(5)**2,(-5)**2,-(5**2)] --Real
print [-5^3,-(5)^3,(-5)^3,-(5^3)] --Integer
print [-5^3,-(5)^3,(-5)^3,-(5^3)] --Integer
print [-5^^3,-(5)^^3,(-5)^^3,-(5^^3)] --Fractional
print [-5**3,-(5)**3,(-5)**3,-(5**3)] --Real</lang>
print [-5**3,-(5)**3,(-5)**3,-(5**3)] --Real</lang>
{{out}}
{{out}}
<pre>[-25,-25,25,-25]
<pre>[-25,-25,25,-25]
[-25.0,-25.0,25.0,-25.0]
[-25.0,-25.0,25.0,-25.0]
[-25.0,-25.0,25.0,-25.0]
[-125,-125,-125,-125]
[-125,-125,-125,-125]
[-125.0,-125.0,-125.0,-125.0]
[-125.0,-125.0,-125.0,-125.0]</pre>
[-125.0,-125.0,-125.0,-125.0]</pre>

=={{header|J}}==
=={{header|J}}==
APLs use a negative sign distinguished from minus as a different character. Underscore followed by a number specifies a negative number. APLs also process the operations from right to left, evaluating parenthesized expressions when the interpreter comes to them. In J, unary plus returns complex conjugate, which won't affect the outcome of this experiment.
APLs use a negative sign distinguished from minus as a different character. Underscore followed by a number specifies a negative number. APLs also process the operations from right to left, evaluating parenthesized expressions when the interpreter comes to them. In J, unary plus returns complex conjugate, which won't affect the outcome of this experiment.