Erlang code explained
- by dagda1
Hi,
I am having a bit of trouble getting my head around the following erlang code
-module(threesix).
-export([quicksort/1]).
quicksort(Pivot, Left, Right, []=_Src) ->
{Left, Pivot, Right};
quicksort(Pivot, Left, Right, [H|T]=_Src) when H < Pivot ->
quicksort(Pivot, [H|Left], Right, T);
quicksort(Pivot, Left, Right, [H|T]=_Src) ->
quicksort(Pivot, Left, [H|Right], T).
quicksort([]) ->
[];
quicksort([H|T]=_List) ->
{Left, Pivot, Right} = quicksort(H, [], [], T),
quicksort(Left) ++ [Pivot] ++ quicksort(Right).
I am specifically talking about the use of _Src and _List in the parameters.
Are these simply for documentation as I cannot see why they are used?
Thanks
Paul