I have DB with those structure
my_family( person("FN","SN", unempl(), 20),
person("FN2","SN", work("Soft", 200), 30),
[person("FN3","SN", work("HP" , 10), 13),
person("FN4","SN", work("LP", 200), 1),
person("FN5","SN" , work("qwerty", 300), 1)]).
domains
family = person*.
person = person(string Name, string LastName, work, integer Age).
work = work(string Corp, real Salary)
How do I get the family, with children's same age?
I try
clauses
length_of([], 0).
length_of([_|T], L):-
length_of(T, TailLength),
L = TailLength + 1.
....
my_family(person(_, _, _, FA), person(_, _, _, MA), Child),
getName(Child).
getName([]).
getName([person(N, S, _, AC)|T]):-
findall(1, _=person(_, S, _, AC), L),
length_of(L, LN),
2 <= LN,
stdIO::writef("Family: %\n\n\n", S),
getName(T).
But it does not work, it seems that findall returns a list L with only one element.
I think you should drop AC in findall
otherwise the list is constrained to people with the very same age of current person. Disclaimer: I can't test that code, and the syntax it's very out of standard: in ISO Prolog, findall/3 works without the _=person(...), but that could be a feature of Visual prolog unknown to me