ProgrammerX
Programmer
Hi, I am trying to sort a list of numbers. I want to do it this way - I remove the minimum number in the list, and insert into a new list. Then I remove the next minimum number and append it to the new list, and so on. This is what I have, but Prolog just answers 'No' to any query.
Please note that the predicates my_append and remove_min, both work correctly.
my_sort([],[]).
my_sort(Unsorted_List,Sorted_List):-
remove_min(Unsorted_List,Min,Unsorted_List),
my_append(Sorted_List,Min,Sorted_List).
my_sort(Unsorted_List,Sorted_List).
I would appreciate some pointers as to where I have gone wrong with this please.
Thank you
Maz
Please note that the predicates my_append and remove_min, both work correctly.
my_sort([],[]).
my_sort(Unsorted_List,Sorted_List):-
remove_min(Unsorted_List,Min,Unsorted_List),
my_append(Sorted_List,Min,Sorted_List).
my_sort(Unsorted_List,Sorted_List).
I would appreciate some pointers as to where I have gone wrong with this please.
Thank you
Maz