domains
para=p(string,integer,string,integer)
pars=para*
database
c(integer)
j(string)
predicates
nondeterm find
nondeterm age(integer)
nondeterm take(para,pars,pars)
goal find.
clauses
find :- j(JA),j(JI),JI<>JA,j(JL),JL<>JA,JL<>JI,
age(AA),age(AI),age(AL),
AWA=AA-5,AWI=AI-5,AWL=AL-5,
2*(AA+AI+AL)=166,
Pars=[p("Андраш",AA,JA,AWA),
p("Ирме",AI,JI,AWI),
p("Ласло",AL,JL,AWL)],
take(p(_,_,"Юлишка",AU),Pars,Rest),
AI+AU=52,
AL+AU=48,
take(p(_,_,"Ева",AE),Rest,[p(_,_,"Марта",AM)]),
AE>AU,AE>AM,
writef("Андраш (%) - % (%)n",AA,JA,AWA),
writef("Ирме (%) - % (%)n",AI,JI,AWI),
writef("Ласло (%) - % (%)nn", AL,JL,AWL),
fail; true.
take(A,[A|L],L).
take(A,[B|L],[B|L1]):- take(A,L,L1).
age(Age):- c(A),A>1,A<5,c(B),Age=A*10+B.
c(1). c(2). c(3). c(4). c(5). c(6). c(7). c(8). c(9). c(0).
j("Юлишка"). j("Ева"). j("Марта"). |