在 Scheme 中如何使用指数?

pow, ^, ** doesn't work, and Scheme seems to be too common a word to be able to effectively google it.

转载于:https://stackoverflow.com/questions/1690925/how-do-i-do-exponents-in-scheme

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

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.

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