16 lines
295 B
Text
16 lines
295 B
Text
{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
|