Returning a list in prolog

前端 未结 1 809
离开以前
离开以前 2021-01-28 06:49

i wanna ask a question about returning a list... Facts:

TEAM(TEAMNAME,DIRECTOR,NATIOANALITY,OVERALLGOAL)

team (milan,allegri,italy, 8.5).
team (int         


        
1条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-28 07:19

    To extract a list of items satisfying a predicate from a database of clauses, one should use findall predicate. For example, your code could be rewritten as follows:

    find(T, N, G) :- findall(X, (team(X, _, N, G0), G0 > G), T).
    

    0 讨论(0)
提交回复
热议问题