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.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to