[Haskell-cafe] Re: All binary strings of a given length

Steve Schafer steve at fenestra.com
Fri Oct 15 09:25:49 EDT 2010


On Fri, 15 Oct 2010 09:16:58 -0400, rgowka1 <rgowka1 at gmail.com> wrote:

>But genbin 32 gives an empty list.. works till 31.

That's because Daniel uses values of type Int as intermediate storage
during the computation, and Int values are only 32 bits long. By
replacing Int with Integer (which does not have that limitation), you
can make it work for larger numbers/longer strings:

 genbin n = map (showFixed n) [0..2^n-1::Integer]

-Steve Schafer


More information about the Haskell-Cafe mailing list