Proposed change to libraries

Carsten Schultz <>
Wed Feb 9 22:44:02 CET 2005


On Wed, Feb 09, 2005 at 12:09:49PM +0100, Kostis Sagonas wrote:
> 
>     map({M,F}, L) -> map(fun(X) -> M:F(X) end, L);
>     map(F, [H|T]) -> [F(H) | map(F, T)];
>     map(F, []) when is_function(F,1) -> [].
> 

How clever is the compiler?  Will it be necessary to write

map({M,F}, L) -> map_(fun(X) -> M:F(X) end, L);
map(F, L) when is_function(F, 1) -> map_(F, L).

map_(F, [H|T]) -> [F(H) | map_(F, T)];
map_(F, []) -> [].

(possibly with additional guards in map_/2, if that makes the
compiler/an analyzer happier) to avoid a performance penalty?

Regards,

Carsten

-- 
Carsten Schultz (2:38, 33:47)
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050209/b34ac214/attachment.bin>


More information about the erlang-questions mailing list