1.
person(P):-man(P).
person(P):-woman(P).
2.dont know how you use childTo.assuming child is first then parents.so:
fatherTo(A,B):-childTo(B,A,_),man(A).
fatherTo(A,B):-childTo(B,_,A),man(A).
3.
father(A):-man(A),childTo(_,A,_).
father(A):-man(A),childTo(_,_,A).
and it goes...
completely theoretical:
your list is like [A,B,C,...,X]
where letters are inner lists.
make a predicate that uses
length(A,Length)
where A is the list you are referring to
and Length is a var that gives you its length.
any help?
have you tried writing it this way?
i know it doesnt answer your question but you need to put that "1" there to make it work.
listprod(X, Y, Sum):-
checkList(X, NewListX, Num1),
checkList(Y, NewListY, Num2),
Sum1 is Sum+(Num1*Num2),
listprod(NewListX, NewListY, Sum1)...
its not complicated at all.
describe all your people as male(name) or female(name) and one basic relationship f.ex. father/mother.
from there on create predicates such as
a)parent(X,Y):-father(X,Y).
parent(X,Y):-mother(X,Y).
b)brother(X,Y):-parent(Z,X),parent(Z,Y),male(X).
[Z is parent both...
for 3b.
display_items([]).
display_items([H|T]):-put(H),display_items(T).
though it produces the elements in the list,it leaves no spaces and also produces a "Yes" in the end.
if it doesnt suit you, try to alter it yourself to meet with your needs.
cartesian_product([H|T],B):- cartesian_product_1(H,B),cartesian_product(T,B).
cartesian_product_1(H,[H1,T1]):- put(H),write( {*spaces*} ),
put(H1),cartesian_product_1(H,T1).
its just a thought.i dont know whether it works, i didnt run it.if i had this problem this is what id think first.
if...
i have the following problem:
i have facts of flights using lists and im trying to find a way to search inside lists.
here's how the facts are described:
flight(london,milan,
[[times(depart(8),arrive(11)),code(ba510),mo,tu,we,th,fr,sa,su]...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.