optimization of list comprehensions
Richard Carlsson
richardc@REDACTED
Wed Mar 8 22:00:21 CET 2006
Richard A. O'Keefe wrote:
> In fact, I spent about 20 minutes looking at foldl calls in the OTP
> sources, [...]
> Here's the only complex example I found in those 20 minutes:
>
> find_modules(P, [Path|Paths], Ext, S0) ->
> case file:list_dir(filename:join(Path, P))
> of {ok, Fs} ->
> S1 = lists:foldl(
> fun(F, S) -> sets:add_element(filename:rootname(F, Ext), S) end,
> S0,
> [F || F <- Fs, filename:extension(F) =:= Ext]),
> find_modules(P, Paths, Ext, S1)
> ; _ ->
> find_modules(P, Paths, Ext, S0)
> end;
> find_modules(_P, [], _Ext, S) ->
> sets:to_list(S).
I feel honored. :-)
/Richard Carlsson
More information about the erlang-questions
mailing list