[erlang-questions] Feedback for my first non-trivial Erlang program

zxq9 zxq9@REDACTED
Tue Dec 15 13:51:03 CET 2015


On 2015年12月15日 火曜日 11:12:24 Technion wrote:
> 
> So there is definitely a measureable improvement there.

The more fundamental problem, though, is that this is a compounding function that steps singly as it increments, but it is written in a way that it counts down, not up, computing the *entire* value chain below it all over again each step, and within each sub-step once the input value is over 60.

Its an arithmetic fun-bomb!

If you remove most of the intermediate functions (I think most but maybe profit/3 can be removed... ?) and compute the stepping values as arguments to an expanded defintion of total_balance this should run close to O(n).

Refactoring for that may also expose some bugs...

-Craig



More information about the erlang-questions mailing list