[erlang-questions] behavior of funktions
Mon Jul 23 01:50:41 CEST 2007
On 7/23/07, Johannes <> wrote:
> i never thought of not-side-effect-free functions in that case ;)
> maybe i chosed a bad example.
> My question is, if there is a function, wich is called more than one
> time with the same arguments, how often is it evaluated(not 'called')?
> it's clear, that a its impossible to save all function results the whole
> time a programm is running, but how is it for example in a rekursion ??
It's easy to test. Try this function:
foo(0) -> 1;
foo(N) -> foo(N-1) + foo(N-1).
time foo(100), and if it takes only a few microseconds then F(N-1) is
evaluated only once. If it takes thousands of years, then it is
More information about the erlang-questions