optimization tricks ?
James Hague
jhague@REDACTED
Tue May 16 04:39:24 CEST 2000
>Since most worthwhile performance increases come from algorithmic
>changes, I'd have to agree with Francesco's methodology. Discussion
>on the list about whether to go for "beauty" first is just a minor
>problem of choosing a decent algorithm ... for some value of decent.
>:-)
You also have to realize the limits of Erlang, or at least the type of
problem it isn't suited for. If your problem is very state-heavy, then
writing it in an imperative language may make sense. Some types of
games--what the orignal poster mentioned--tend to lean more toward the
imperative side of things. Might be able to get away with just using ETS
or process tables in lieu of variables. Be interesting to try.
One tiny code improvement that isn't used in many older examples is this:
dumb_example({X,Y}, L) -> {X+Y, {X,Y}}.
can be replaced by:
dumb_example({X,Y}=A, L) -> {X+Y, A}.
The second version avoids rebuilding the {X,Y} tuple, or so I've been
told :)
James
More information about the erlang-questions
mailing list