Calling a Function with Same argument twice

sapan shah sapan.gcet@REDACTED
Wed Oct 14 15:09:12 CEST 2009


see the code below.

start(X) ->
    put(test, 0),
    case X of 1 -> test(2, 2); 2-> test1(2) end,

test(0,0) ->
    put(test, get(test) +1),

test(X,Y) ->

test1(0) ->
    put(test, get(test) +1),
test1(X) ->

We call temp:start(1), the output is 4. The output should have been 1.
Here, when start(1) is called, it intern calls
{element(1, test(1,1), element(2, test(1,1)}

The first call of test(1,1) should recursively evaluate test(1,1) while the
second call should already use the value returned by the first call.. Is
this a right thinking???
Sapan Shah

More information about the erlang-questions mailing list