
15 Feb
2007
15 Feb
'07
4:06 a.m.
G'day all.
Quoting Dougal Stanton
Is there a better way to turn an integer N and a list of primes [p1,p2,p3,...] into powers [c1,c2,c3,...] such that
N = product [p1^c1, p2^c2, p3^c3, ...]
It depends what you mean by "better". You can make it more concise by using zip or zipWith: product (zipWith (^) ps cs) If you're after performance, that's another issue entirely. For large integers, you're using entirely the wrong algorithm. Cheers, Andrew Bromage