Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bagof/3 issue #28

Closed
flexoron opened this issue Aug 24, 2022 · 3 comments
Closed

bagof/3 issue #28

flexoron opened this issue Aug 24, 2022 · 3 comments

Comments

@flexoron
Copy link

flexoron commented Aug 24, 2022

v2.1.4

$ cat xyz.pl

isl({L},N) :- L = (_ is _+N).

testf :- findall(Z,(between(1,5,N),
                    (isl({X}, N), X = (Y is B+_), bagof(Y,X^B^(between(1,3,B),X),Z))
		   ),
	         M), write(M).

testb :- bagof(Z,N^X^Y^B^(between(1,5,N),
                          (isl({X}, N), X = (Y is B+_), bagof(Y,X^B^(between(1,3,B),X),Z))
	                 ),
	       M), write(M).
$ tpl xyz.pl
?- testf.
[[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8]]   true.

?- testb.
[[2,3,4]]   true  % unexpected? expecting the whole list(see testf).
; [[3,4,5]] true
; [[4,5,6]] true
;  ... .
?-

testf: findall/3 works as expected and gathers up Z of (sub-)bagof/3, which works as expected, into M.

testb: bagof/3 does not collecting Z as findall/3 does but it should, shouldn't it?

@infradig
Copy link
Contributor

infradig commented Aug 24, 2022 via email

@infradig
Copy link
Contributor

infradig commented Aug 24, 2022 via email

@flexoron
Copy link
Author

flexoron commented Aug 24, 2022

True! N^X^W^ is good enough, Y^B^ not needed. Thanks a lot!

testb :- bagof(Z,N^X^W^(between(1,5,N),
isl({X}, N), X = (Y is B+W), bagof(Y,X^B^(between(1,3,B),X),Z)
),
M), write(M).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants