1
may(_,[],[]).
may(num(U),[est(C1,N1,NT1)|T1],[est(C1,N1,NT1)|T2]):-
U =< NT1,
may(num(U),T1,T2).
min(_,[],[]).
min(num(U),[est(C2,N2,NT2)|T3],[est(C2,N2,NT2)|T4]):-
U > NT2,
min(num(U),T3,T4).
main:-
U is 2.0,
mayores(num(U),
[ est(3,"J",3.1), est(6,"P",4.5), est(7,"L",2.0), est(4,"R",1.5),
est(2,"C",4.7), est(5,"F",2.0), est(9,"A",3.5), est(11,"K",4.8),
est(8,"M",2.4), est(15,"S",1.5), est(17,"D",0.5), est(19,"G",2.0)
],
T2),
menores(num(U),
[ est(3,"J",3.1), est(6,"P",4.5), est(7,"L",2.0), est(4,"R",1.5),
est(2,"C",4.7), est(5,"F",2.0), est(9,"A",3.5), est(11,"K",4.8),
est(8,"M",2.4), est(15,"S",1.5), est(17,"D",0.5), est(19,"G",2.0)
],
T4),
write(T4),
write(T2),
halt.
:- main.
代碼需要分成不同的列表值< = 2和值> 2。但是當我將它運行到ideone時它給了我這個錯誤。目標(指令)失敗:用戶:主要序言swi
Goal (directive) failed: user:main.
您正在使用'mayores'和'may' ... – false