diff --git a/prolog/stalin_sort.pl b/prolog/stalin_sort.pl new file mode 100644 index 0000000..c554f08 --- /dev/null +++ b/prolog/stalin_sort.pl @@ -0,0 +1,5 @@ +stalinSortAux([], _, []). +stalinSortAux([H1|T1], [H2|T2], [H1|R]):- H1>H2, !, stalinSortAux(T1, T2, R). +stalinSortAux([_|T1], [H2|T2], R):- stalinSortAux(T1, [H2|T2], R). + +stalinSort([H|T], [H|R]):- stalinSortAux(T, [H|T], R).