[Haskell-cafe] Combination-lock problem

Fritz Ruehr fruehr at willamette.edu
Thu Aug 12 15:06:02 EDT 2004


Well, as far as that goes, we can shave off a little bit (around 7%) 
this way:

   combs = mapM (\k->[0..k])

(As a bonus, it's even a bit more cryptic/symbolic, in the fine 
tradition of APL one-liner character-shavings.)

But who's counting? :) :) :)

   --  Fritz Ruehr

On Aug 11, 2004, at 3:22 PM, Mike Gunter wrote:

>
> Why so long-winded :-)?
>
>   combs = mapM (enumFromTo 0)
>
> 	mike
>
> Lyle Kopnicky <lists at qseep.net> writes:
> ...
>> Here is the
>> improved version:
>>
>> combs [] = [[]]
>> combs (n:r) = [i:cr | i <- [0..n], cr <- combs r]
> ...
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list