[erlang-questions] behavior of funktions
Christian S
chsu79@REDACTED
Sun Jul 22 23:32:52 CEST 2007
In your case it wont change the result since f is side-effect free
(ignoring heat dissipation in the computer). Optimizing compilers
might take advantage of this.
The semantics is to call f twice, and as you write the way to get
around it is to
save the value into a temporary.
2007/7/22, Johannes <dajo.mail@REDACTED>:
> hi, i have a question about the behavior of funktions.
> if theres a function:
> f(A,0) ->
> 1;
> f(A,B) ->
> [f(A,B-1),f(A,B-1)].
> how often is f(A,B-1) evaluated then ? just one time, and erlang tooks
> the result everywhere where it fits, like f(A,B) -> TMP=f(A,B-1),[TMP;TMP].
> or is it evaluated every time again ??
More information about the erlang-questions
mailing list