开发者

How do I do exponents in Scheme?

开发者 https://www.devze.com 2022-12-10 14:26 出处:网络
pow, ^, ** doesn\'开发者_C百科t work, and Scheme seems to be too common a word to be able to effectively google it.From R5RS Standard Pocedures:

pow, ^, ** doesn'开发者_C百科t work, and Scheme seems to be too common a word to be able to effectively google it.


From R5RS Standard Pocedures:

(expt z1 z2) 

Returns z1 raised to the power z2. For z1 0

z1z2 = ez2 log z1

0z is 1 if z = 0 and 0 otherwise.

Searching for "scheme reference" turns up this document.


The answer is expt and I am typing because StackOverflow doesn't like too short answers.


(expt base power) is what you want. So (expt 2 3) expresses 2^3 and yields 8.

0

精彩评论

暂无评论...
验证码 换一张
取 消