10 Feb
2008
10 Feb
'08
4:07 p.m.
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 My guess is that the latter is more efficient, but then when I think about laziness, I wonder whether the first is a fair trade. Michael