Being curious, I thought I'd try to avoid floats and make an integer pow function...
<pre>
-module(intpow).
-export([pow/2]).
pow(X, 0) -> 1;
pow(X, Y) -> X * pow(X, Y-1).
</pre>
Neat. It hadn't even occurred to me that it might just be simpler to implement it myself. For something fairly basic, my instinct is still to look in the standard library first.
Ian Bicking - 2006-08-21 02:19:37
Being curious, I thought I'd try to avoid floats and make an integer pow function... <pre> -module(intpow). -export([pow/2]). pow(X, 0) -> 1; pow(X, Y) -> X * pow(X, Y-1). </pre>anders pearson - Mon 21 Aug 2006 10:29:08
Neat. It hadn't even occurred to me that it might just be simpler to implement it myself. For something fairly basic, my instinct is still to look in the standard library first.