Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Findall with multiple variables in Prolog

I would like to get a list of solutions from a rule I made in Prolog.

However the findall predicate appears to only work with one variable.

Can anyone suggest how to get around this apparent limitation?

My rule

beat(P,M,E)

What I want

L = [[P,M],[P,M],................]

What I get now

L = [P,P,P,P,.........]

or

L = [M,M,M,M,M.............]
like image 983
ReiiYuki Avatar asked Jan 06 '23 05:01

ReiiYuki


1 Answers

findall can work with a surprisingly flexible amount of variations. I think you want something like this:

findall([P,M], beat(P,M,E), L).
like image 149
eazar001 Avatar answered Feb 03 '23 20:02

eazar001