У меня есть проблема, у меня есть это:
start :- welcome,
make_conf,
undo.
make_conf это:
make_conf :-
interface,
define_motherboard(Use, Price_range),
define_processor(Use, Price_range, Best_processor, Price_bestprocessor, Best_motherboard),
...
определить процессор это:
define_processor(Use, Price_range, Best_processor, Price_bestprocessor, Best_motherboard) :-
% find the best processor
setof(Score-Nome-Price,Price_range^Use^processor(Nome, Price, Price_range, Use, Score),Pairs2),
sort(1,@>,Pairs2,[_-Best_processor-Price_bestprocessor|Rest]),
%check compatibility between processor and motherboard
(motherboard_processor(Best_motherboard, Best_processor) -> write('');
choose_another_processor(Rest, Best_motherboard, Best_processor, Price_bestprocessor)),
write('proc2:'),write(Best_processor),nl.
choose_another_processor(Rest, Best_motherboard, Best_processor, Price_bestprocessor) :-
[_-Best_processor-Price_bestprocessor|Rest2] = Rest,
write('bestproc:'),write(Best_processor),nl,
(motherboard_processor(Best_motherboard,Best_processor) -> write('');
choose_another_processor(Rest2, Best_motherboard, Best_processor, Price_bestprocessor)).
Проблеманаходится в choose_another_processor, я должен проверить совместимость между вторым элементом списка и материнской платой, но перед печатью bestproc произошел сбой, поэтому проблема в этой строке:
[_-Best_processor-Price_bestprocessor|Rest2] = Rest,