[Haskell-cafe] Cost: (:) vs head

michael rice nowgate at yahoo.com
Fri Sep 10 23:13:50 EDT 2010


Which of these would be more costly for a long list?

f :: [Int] -> [Int]
f [x] = [x]
f (x:xs) = x + (head xs) : f xs

f :: [Int] -> [Int]

f [x] = [x]

f (x:y:xs) = x + y : f (y:xs)

Michael






      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100910/0b3a5748/attachment.html


More information about the Haskell-Cafe mailing list