
14 Nov
2007
14 Nov
'07
2:05 p.m.
On Wed, 14 Nov 2007, Kurt Hutchinson wrote:
As part of a solution I'm working on for Project Euler problem 119, I wanted to create an ordered list of all powers of all positive integers (starting with squares). This is what I came up with:
powers = ( uniq . map fst . iterate next ) ( 1, ( 0, powertable ) )
powertable = map (\ n -> map (\ p -> n ^ p ) [ 2 .. ] ) [ 2 .. ]
iterate (n*) (n^2) should be much more efficient.