我有那些结构的数据库
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)
我如何获得家庭,与孩子同龄?
我试试
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).
但它不起作用,似乎 findall 返回一个只有一个元素的列表 L。