-
Notifications
You must be signed in to change notification settings - Fork 13
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
Comments
It's the same with SWI Prolog.
- ~/trealla (devel) $ swipl xyz.pl
?- testf.
[[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8]]
true.
?- testb.
[[2,3,4]]
true ;
[[3,4,5]]
true ;
[[4,5,6]]
true ;
[[5,6,7]]
true ;
[[6,7,8]]
true.
…On Thu, Aug 25, 2022 at 7:17 AM flexoron ***@***.***> wrote:
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
; [[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?
—
Reply to this email directly, view it on GitHub
<#28>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNKSEXUYTDITRRNM6QIMQTV22GOLANCNFSM57QZSYKQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The problem is the anonymous variable, replace it with W like this...
testb :- bagof(Z,N^X^Y^W^B^(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).
…On Thu, Aug 25, 2022 at 7:17 AM flexoron ***@***.***> wrote:
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
; [[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?
—
Reply to this email directly, view it on GitHub
<#28>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNKSEXUYTDITRRNM6QIMQTV22GOLANCNFSM57QZSYKQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
True! N^X^W^ is good enough, Y^B^ not needed. Thanks a lot! testb :- bagof(Z,N^X^W^(between(1,5,N), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v2.1.4
testf: findall/3 works as expected and gathers up
Z
of (sub-)bagof/3, which works as expected, intoM
.testb: bagof/3 does not collecting
Z
as findall/3 does but it should, shouldn't it?The text was updated successfully, but these errors were encountered: