<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Henning,<br><br>Thanks for the tip, I'll check it out.<br><br>A related but more general question: on average, what's more efficient, pattern matching or function calls?<br><br>Michael<br><br>--- On <b>Sun, 9/12/10, Henning Thielemann <i>&lt;schlepptop@henning-thielemann.de&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Henning Thielemann &lt;schlepptop@henning-thielemann.de&gt;<br>Subject: Re: [Haskell-cafe] Cost: (:) vs head<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: haskell-cafe@haskell.org<br>Date: Sunday, September 12, 2010, 8:47 AM<br><br><div class="plainMail">michael rice schrieb:<br>&gt; Which of these would be more costly for a long list?<br>&gt; <br>&gt; f :: [Int] -&gt; [Int]<br>&gt; f [x] = [x]<br>&gt; f (x:xs) = x + (head xs) : f xs<br>&gt; <br>&gt; f
 :: [Int] -&gt; [Int]<br>&gt; f [x] = [x]<br>&gt; f (x:y:xs) = x + y : f (y:xs)<br><br>What about empty lists? How about<br>&nbsp; zipWith (+) xs (drop 1 xs ++ [0]) ?<br><br>Since I often need to combine adjacent list elements, I have defined<br>mapAdjacent in utility-ht.<br></div></blockquote></td></tr></table><br>