User:Eriksiers/Alternate CLISP exponentiation: Difference between revisions
User:Eriksiers/Alternate CLISP exponentiation (view source)
Revision as of 04:57, 1 September 2022
, 1 year agoupdated lang tag
m (added footnote to Ahungry's example) |
m (updated lang tag) |
||
Line 1:
This is a better example of exponent (it doesn't solve for negatives however so I will leave in tact the other example):
<
(defun ^ (a b)
(let ((r 1))
(dotimes (x b r)
(setf r (* r a)))))
</syntaxhighlight>
<small>(The above example is by [[User:Ahungry|Ahungry]].)</small>
Line 16:
Later, I might update this to handle [[Nth root|b as a float]].
<
; b must be an integer
; a can be integer or floating-point
Line 39:
)
)
)</
Sample outputs:
|