Commit 466400b8 authored by Ilya Prokhorov's avatar Ilya Prokhorov

Pre multi pass implementation

parent 70e90bfd
......@@ -10,7 +10,12 @@ compareHeads(CurrentHead, [NextHead|Tail], []) ->
io:format("CurrentHead: ~w~n", [CurrentHead]),
io:format("NextHead: ~w~n", [NextHead]),
compareHeads(NextHead, Tail, [CurrentHead]);
if
CurrentHead < NextHead ->
compareHeads(NextHead, Tail, [CurrentHead]);
true ->
compareHeads(CurrentHead, Tail, [NextHead])
end;
compareHeads(CurrentHead, [NextHead|Tail], [OutputListHead|OutputListTail]) ->
io:fwrite("---\n"),
......@@ -18,8 +23,17 @@ compareHeads(CurrentHead, [NextHead|Tail], [OutputListHead|OutputListTail]) ->
io:format("CurrentHead: ~w~n", [CurrentHead]),
io:format("NextHead: ~w~n", [NextHead]),
OutputList = lists:append([[OutputListHead], OutputListTail, [CurrentHead]]),
compareHeads(NextHead, Tail, OutputList);
% OutputList = lists:append([[OutputListHead], OutputListTail, [CurrentHead]]),
% compareHeads(NextHead, Tail, OutputList);
if
CurrentHead < NextHead ->
OutputList = lists:append([[OutputListHead], OutputListTail, [CurrentHead]]),
compareHeads(NextHead, Tail, OutputList);
true ->
OutputList = lists:append([[OutputListHead], OutputListTail, [NextHead]]),
compareHeads(CurrentHead, Tail, OutputList)
end;
compareHeads(CurrentHead, [], [OutputListHead|OutputListTail]) ->
io:fwrite("---\n"),
......@@ -28,5 +42,5 @@ compareHeads(CurrentHead, [], [OutputListHead|OutputListTail]) ->
io:fwrite("End\n").
start() ->
UnsortedList = [4,7,1,2,9,10],
UnsortedList = [7,4,1,2,9,10],
startBubbleSort(UnsortedList).
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment