I have just started learning erlang...I am just practicing the recursion and all in erlang...I tried to write a few of the list processing functions on my own in erlang...Can someone review the code and give some advice on it...
-module(listma).
-export([duplicates/1,reverse/1])
%% Remove the duplicates in a list
duplicates(List) ->
duplicates(List,[]).
duplicates([Head|Tail],Newlist) ->
Insert =
fun(H,N) ->
case [H] -- N of
[] -> N;
[H] -> [H|N]
end
end,
duplicates(Tail,Insert(Head,Newlist));
duplicates([],Outputlist) ->
reverse(Outputlist).
%% Reverse a list
reverse(List) ->
reverse(List,[]).
reverse([Head|Tail],Newlist) ->
reverse(Tail,[Head|Newlist]);
reverse([],Outputlist) ->
Outputlist.