Erlang code explained
Posted
by dagda1
on Stack Overflow
See other posts from Stack Overflow
or by dagda1
Published on 2010-05-16T13:58:58Z
Indexed on
2010/05/16
14:00 UTC
Read the original article
Hit count: 385
erlang
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
© Stack Overflow or respective owner