Exponentiation operator: Difference between revisions
Content added Content deleted
(Added AppleScript implementation.) |
No edit summary |
||
Line 1,468: | Line 1,468: | ||
4.5 ^ 2 = 20.25 |
4.5 ^ 2 = 20.25 |
||
</pre> |
</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}}== |
=={{header|Liberty BASIC}}== |