[Haskell-cafe] Style and a problem
Wanas
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):
import Data.List
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...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100910/6fbeaef2/attachment.html
More information about the Haskell-Cafe
mailing list