Jump to content

Exponentiation operator: Difference between revisions

no edit summary
(Added AppleScript implementation.)
No edit summary
Line 1,468:
4.5 ^ 2 = 20.25
</pre>
 
=={{header|Lambdatalk}}==
 
Following the example given in Scheme
 
<lang scheme>
{def ^
{def *^
{lambda {:base :exponent :acc}
{if {= :exponent 0}
then :acc
else {*^ :base {- :exponent 1} {* :acc :base}}}}}
{lambda {:base :exponent}
{*^ :base :exponent 1}}}
-> ^
 
{^ 2 3}
-> 8
{^ {/ 1 2} 3}
-> 0.125 // No rational type as primitives
{^ 0.5 3}
-> 0.125
</lang>
 
=={{header|Liberty BASIC}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.