
I see. Did not got the filterM part in mind. Thanks.
On Sat, May 18, 2019 at 1:48 PM Francesco Ariis
Hello,
On Sat, May 18, 2019 at 12:33:00PM +0800, Magicloud Magiclouds wrote:
I solved the question. But I could not figure out a FP style solution.
Question:
1 - 9, nine numbers. Show all the possible combinations that sum up to 10. Different orders are counted as the same.
A possible solution takes advantage of powersets with the [] Monad.
λ> :m +Control.Monad λ> f cs = filterM (\x -> [True, False]) cs λ> filter ((==10) . sum) (f [1..10])
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.