[Haskell-cafe] Help with generalizing function
chaddai.fouche at gmail.com
Mon Jun 23 05:42:25 EDT 2008
2008/6/23 leledumbo <leledumbo_cool at yahoo.co.id>:
> I give up %-|, I'll go back to Pascal instead. Thanks for your answers.
Don't give up so fast !! (Note that you can't do what you asked for in
Pascal either, in fact Pascal don't support n-uplet)
A recursive way to do it is :
findAllAns 0 0 = []
findAllAns 0 s = 
findAllAns n s = [ x:xs | x <- [0..s], xs <- findAllAns (n - 1) (s - x) ]
For all those little questions that bug you, you'll get your answers
faster by asking on the #haskell channel on irc.freenode.org .
More information about the Haskell-Cafe