On Sun, 10 Feb 2008, Michael Feathers wrote:

> How bad is this:
>
> addProduct :: [Product] -> Product -> [Product]
> addProduct inventory product = nub (product : inventory)
>
>
> compared to this:
>
> addProduct :: [Product] -> Product -> [Product]
> addProduct inventory p
>     | isNothing (find (==p) inventory)    = p : inventory
>     | otherwise                                        = inventory

Data.Set is first choice, 'elem' is second choice, but still better than
'isNothing (find ...)'.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to