How to use exponents in PureScript
I’m doing the exercises for PureScript By Example and I needed to raise a number to a power. (exponentiate: to use an exponent). This was not obvious to me. A couple of hints:
-
Remember that JavaScript uses Math.pow — [^](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR) is a bitwise XOR operator that has nothing to do with exponentiation.
-
Use Pursuit to search for Pow. … Wow, that’s a lot of options. It really depends on the type you want to exponentiate. How about a simple Number? It’s actually the fourth one in the list. Math.pow
Here’s how to use it:
import Math (pow)
pow 2.0 4.0
-> 16