0
votes

I have to make a prolog program, and I have to find all combinations that meet those conditions:

... code... function(..., List), findall(clause, goal, C) where goal = (between(1,N,X), member(X, List))

I can't find out how to do it.

It can be with bagof too if anyone knows how.

1
just put your goals as you stated, i.e: findall(X, (between(1,N,X), member(X,List)), C). This will unify C with the list of numbers between 1 and N that are contained in List.gusbro
is it the same: findall( x-A-AS, (between(1,NA,A),member(A,L)) than: bagof( x-A-AS, between(1,NA,A)^member(A,L), C) @gusbroDaniel Roca Lopez
The constructs you posted make no sense to me. Check the documentation of findall/3 and bagof/3.gusbro
@DanielRocaLopez: It is not the same, if there is no solution - e.g. L = []: findall/3 will find [] but bagof/3 will failfalse

1 Answers

0
votes

I found my mistake, I had to put both goals between brackets:

findall(clause, (goal, goal2), C)