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.
The code needs to separate into different list the values <=2 and the values >2. but it gave me this error when i run it into ideone.
Goal (directive) failed: user:main.
mayores
andmay
... – false