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

11 lines
242 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(de ** (X N) # N th power of X
(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 ) )