Not in the standard library. But you can easily write one (using exponentiation, squaring to be fast), or reuse the extended library that provides this. At Batteries, it's Int.pow .
Below is a suggested implementation:
let rec pow a = function | 0 -> 1 | 1 -> a | n -> let b = pow a (n / 2) in b * b * (if n mod 2 = 0 then 1 else a)
If there is a risk of overflow because you are manipulating very large numbers, you should probably use a library with a large integer such as Zarith , which provides all kinds of exponential functions.
(You might need a “modular exponentiation”, a computation of (a^n) mod p , which can be done in such a way as to avoid overflow by applying the mod in intermediate calculations, for example, in the pow function above.)
gasche
source share