'What does _ (Underscore) mean in this context in Prolog Amzi
I have been trying to learn some Prolog Amzi. This is an example question and can't quite wrap my head around this question.
This is the code.
/* Facts */
parent(mary,tom).
parent(john,tom).
parent(mary,alice).
parent(john,alice).
sex(mary, female).
sex(john, male).
sex(tom, male).
sex(alice, female).
/* Rules */
mother(X):-
sex(X,female),
parent(X,_).
father(X):-
sex(X, male),
parent(X,_).
sibling(X,Y):-
parent(M,X),
sex(M,female),
parent(F,X),
sex(F,male),
parent(M,Y),
parent(F,Y).
sibling1(X,Y):-
parent(M,X),
sex(M,female),
parent(F,X),
sex(F,male),
parent(M,Y),
parent(F,Y),
X \= Y.
go:-
nl, nl,
write('Hello there .....'), nl,
write('Testing on Prolog2.'), nl,
write('End Job'), n1.
The question asks what the function of the underscore in the rules mother(X) and father(X) is with examples of output.
I don't seem to understand what the underscore means in this context and what it means by example output.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
