Hi,
I am really struggling to understand tail recursion in Erlang.
I have the following eunit test:
db_write_many_test() ->
Db = db:new(),
Db1 = db:write(francesco, london, Db),
Db2 = db:write(lelle, stockholm, Db1),
?assertEqual([{lelle, stockholm},{francesco, london}], Db2).
And here is my implementation:
-module(db) .
-include_lib("eunit/include/eunit.hrl").
-export([new/0,write/3]).
new() ->
[].
write(Key, Value, Database) ->
Record = {Key, Value},
[Record|append(Database)].
append([H|T]) ->
[H|append(T)];
append([]) ->
[].
Is my implementation tail recursive and if not, how can I make it so?
Thanks in advance