
Am 09.09.2010 22:55, schrieb Wanas:
Hey all,
So I have a two part question (I'm new to haskell, so you can throw all your mugs at me).
a) I want to write a function that generates lists of lists of size $n$. All having the property that sum lst = sum [1..n]. a-1) After that, I want to remove all permutations. My idea of doing this is to get all lists from the first function and create a new list with the property that "if sorted list A is not in the list, add it."
b-2) I think that's too much questions, but I want to get the hang of this quickly (it was kickass for the few things I've tried out).
Something like this? import Data.List newList :: Int -> [[Int]] newList n = myNub [ l | l <- undefined -- not really sure how you want -- to generate these lists :) , sum l == sum [1..n] ] myNub :: (Ord a) => [[a]] -> [[a]] myNub = nubBy (\a b -> sort a == sort b) - Nils