i am new in prolog and I trying to achieve the following:
I have these 2 rules so far.
family(
person(tom, fox, date(7, may, 1950), works(bbc, 15200)),
person(ann, fox, date(9, may, 1951), unemployed),
[person(pat, fox, date(5, may, 1973), unemployed),
person(jim, fox, date(5, may, 1973), unemployed)]
).
child(X):-
family(_, _, Children),member(X, Children).
When I call the child(X) I get:
X = person(pat, fox, date(5, may, 1973), unemployed) ;
X = person(jim, fox, date(5, may, 1973), unemployed)
and what I seek to do is find whether a child is unemployed. But since X is returning the person() and not a single value, how can I access only the last element of this rule and check if its value is equal to "unemployed"? So basically I want to create a new rule looking something like this:
childworking(X):-
child(X), (check if the last value of the person() is equal to unemployed).
If the value of child(X) was returned in a list I could do something like child(X),member(unemployed,X) but this is not the case...
Thank you!