I am attempting to create a function that stores a number into a record and then adds value X to that number every time the function runs.
Value: 5
Run Function
-record(adder, {value = 5}).
add(Value) ->
add(#adder{}, Value).
add(#adder{value =V} = Adder, Value) ->
Adder#adder{value = V + Value}.
test() ->
R1 = add(1),
io:format("~p~n", [R1]),
R2 = add(R1, 10),
io:format("~p~n", [R2]).
Here is the output of running test:test().
6> c(test).
{ok,test}
7> test:test().
{adder,6}
{adder,16}
ok