RosettaCodeData/Task/Exponentiation-operator/PicoLisp/exponentiation-operator.l

11 lines
242 B
Text
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
(de ** (X N) # N th power of X
2014-01-17 05:32:22 +00:00
(if (ge0 N)
(let Y 1
(loop
(when (bit? 1 N)
(setq Y (* Y X)) )
(T (=0 (setq N (>> 1 N)))
Y )
(setq X (* X X)) ) )
0 ) )