Prolog findall/3
问题 Say I have a predicate pred containing several facts. pred(a, b, c). pred(a, d, f). pred(x, y, z). Can I use findall/3 to get a list of all facts which can be pattern matched? for example, if I have pred(a, _, _) I would like to obtain [pred(a, b, c), pred(a, d, f)] 回答1: Just summing up what @mbratch said in the comment section: Yes, but you have to make sure that you either use named variables or construct a simple helper predicate that does that for you: Named variables: findall(pred(a,X,Y)