[Haskell-cafe] optimization of recursive functions

Alp Mestanogullari alpmestan at gmail.com
Wed Feb 13 14:57:52 CET 2013


If a difference appears, I believe
http://blog.johantibell.com/2010/09/static-argument-transformation.htmlwould
be involved. Also, the second map function could be inlined by GHC,
avoiding calling "f" through a pointer because at the call site, we know
what 'f' is (this is also mentionned in the blog post by Johan).


On Wed, Feb 13, 2013 at 9:55 AM, Andrew Polonsky
<andrew.polonsky at gmail.com>wrote:

> Hello,
>
> Is there any difference in efficiency between these two functions, when
> compiled with all optimizations?
>
> map f [] = []
> map f (a:as) = f a : map f as
>
> and
>
> map f x = map' x where
>    map' [] = []
>    map' (a:as) = f a : map' as
>
> Thanks,
> Andrew
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
Alp Mestanogullari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130213/4e10a675/attachment.htm>


More information about the Haskell-Cafe mailing list