[Haskell] rekursive array problem
Mirko Rahn
rahn at ira.uka.de
Mon May 2 11:47:23 EDT 2005
Andreas Fuertig wrote:
> fillArray ["a"]
> [[("a",True)],[("a",False)]]
>
> fillArray ["a","b"]
> [[("a",True),("b",True)],[("a",False),("b",True)],[("a",True),("b",False)],
> [("a",False),("b",False)]]
A simple solution is:
fill :: [a] -> [[(a,Bool)]]
fill [] = [[]]
fill (x:xs) = do v <- [True,False] ; vs <- fill xs ; return ((x,v):vs)
have fun,
--
-- Mirko Rahn -- Tel +49-721 608 7504 --
--- http://liinwww.ira.uka.de/~rahn/ ---
More information about the Haskell
mailing list