[Haskell-cafe] Style and a problem
elhassan.wanas at gmail.com
Fri Sep 10 05:24:39 EDT 2010
On Fri, Sep 10, 2010 at 1:06 AM, Nils Schweinsberg <ml at n-sch.de> wrote:
> 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
So I've checked out this code, and it doesn't compile on ghci. My version,
without the "undefined" portion is(which still doesn't work):
newList :: Int -> [[Int]]
newList n = myNub [ l | l <- [1..n], sum l == sum [1..n] ]
myNub :: (Ord a) => [[a]] -> [[a]]
myNub = nubBy (\a b -> sort a == sort b)
Maybe there's something in the syntax that I'm not quite getting...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe