15 Oct
2010
15 Oct
'10
12:25 p.m.
Not the most efficient, but easy to understand: genbin 0 = [] genbin 1 = ["0", "1"] genbin i = map ('0' :) x ++ map ('1' :) x where x = genbin $ i - 1 On Fri, Oct 15, 2010 at 2:21 PM, rgowka1 <rgowka1@gmail.com> wrote:
Hi -
How can I generate all binary string of a given length? The type signature would something like -
genbin :: Int -> [String]
For example genbin 2 would give ["00","11","01","10"] and genbin 3 would give ["000","001","010","011","100","101","110","111"] etc..
thanks.. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe