[Haskell-cafe] Combination-lock problem

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Wed Aug 11 13:01:18 EDT 2004


On Wed, 11 Aug 2004, Lyle Kopnicky wrote:

> Here's my version:
> 
> combs [] = []
> combs [n] = [[i] | i <- [0..n]]
> combs (n:r) = let combsr = combs r in [i:cr | i <- [0..n], cr <- combsr]

Since there is one zero combination, it should be

> combs [] = [[]]

Then you can also remove the definition of combs [n] .

What is the advantage of introducing 'combsr' instead of using 'combs r'
immediately? 




More information about the Haskell-Cafe mailing list