In prolog how do I insert X in its correct position in a sorted list?
My Attempt:
insert(X,[Y|Rest],[X,Y|Rest]):-
X @< Y;
insert(X,Rest,BiggerRest).
In prolog how do I insert X in its correct position in a sorted list?
My Attempt:
insert(X,[Y|Rest],[X,Y|Rest]):-
X @< Y;
insert(X,Rest,BiggerRest).
You're on the right track, but you need to make this three cases.