I Need help .I've done a small sort algorithm :
%give the max Element of a List
max([A],A):-!.
max([X|Xs],M):- max(Xs,M1), M1 > X , M is M1, !.
max([X|_],M):- M is X.
%Delete the element M from list and give back Lo
delete(_,[],[]):-!.
delete(M,[M|Lo],Lo):- !.
delete(M,[X|Xs],L1):- delete(M,Xs,Lo), L1 = [X|Lo].
%sort a list of number with no repetitions
sort([],[]):-!.
sort(L,Lo):- max(L,M), delete(M,L,L1), sort(L1,L2), Lo = [M|L2].
It DOES works, but only for 9 numbers in a list.
For example,
sort([4,5,9,1,2,44,21,10,15],Lo) does
Lo = [44, 21, 15, 10, 9, 5, 4, 2, 1].
but if i write
sort([5,4,6,7,27,2774,22,1,0,10,22,900,8],Lo).
Lo = [2774, 900, 27, 22, 22, 10, 8, 7, 6|...].
i dont understand the " |... " Is my code wrong? Doenst it support more than 9 number? is overflow?