Dear Everyone:
I am a new starter,and make a programme: here are the code:
matchsort([H|T],YList,XList,[N|M]) :-
nth1(Index,YList,H),
write('******'),nl,write(H),nl,
nth1(Index,XList,N),
write(N),nl,write('------'),nl,
matchsort(T,YList,XList,M).
matchsort([],[],[],[]).
run with
"matchsort([17,12,8,5,4],[4,8,12,5,17],[3,9,6,4,9],List)."
the results are:
******
17
9
------
******
12
6
------
******
8
9
------
******
5
4
------
******
4
3
------
false.
No 'List' value....and with false...
With this false problem, I made some changes, the code are changed as:
matchsort([H|T],YList,XList,[N|M]) :-
nth1(Index,YList,H),
write('******'),nl,write(H),nl,
nth1(Index,XList,N),
write(N),nl,write('------'),nl,
matchsort(T,YList,XList,M).
matchsort([],YList,XList,[]).
run this with
"matchsort([17,12,8,5,4],[4,8,12,5,17],[3,9,6,4,9],List)."
get the results:
******
17
9
------
******
12
6
------
******
8
9
------
******
5
4
------
******
4
3
------
*********[9, 6, 9, 4, 3]
true .
here I get the value of List and true, I donot know why I can get this result,especially for the List value, could you give me explainations about these?
Many Thanks for your patience for New starter like me.
I am a new starter,and make a programme: here are the code:
matchsort([H|T],YList,XList,[N|M]) :-
nth1(Index,YList,H),
write('******'),nl,write(H),nl,
nth1(Index,XList,N),
write(N),nl,write('------'),nl,
matchsort(T,YList,XList,M).
matchsort([],[],[],[]).
run with
"matchsort([17,12,8,5,4],[4,8,12,5,17],[3,9,6,4,9],List)."
the results are:
******
17
9
------
******
12
6
------
******
8
9
------
******
5
4
------
******
4
3
------
false.
No 'List' value....and with false...
With this false problem, I made some changes, the code are changed as:
matchsort([H|T],YList,XList,[N|M]) :-
nth1(Index,YList,H),
write('******'),nl,write(H),nl,
nth1(Index,XList,N),
write(N),nl,write('------'),nl,
matchsort(T,YList,XList,M).
matchsort([],YList,XList,[]).
run this with
"matchsort([17,12,8,5,4],[4,8,12,5,17],[3,9,6,4,9],List)."
get the results:
******
17
9
------
******
12
6
------
******
8
9
------
******
5
4
------
******
4
3
------
*********[9, 6, 9, 4, 3]
true .
here I get the value of List and true, I donot know why I can get this result,especially for the List value, could you give me explainations about these?
Many Thanks for your patience for New starter like me.