Hi community,
I am a bit confused why in test7
i get a second solution in which IN
is [p(A), p(A)]
. This does not happen with nth1/4 as shown in test8
. Does select/3 somehow unify p(A)
and p(B)
?
Cheers/JCR
test7:-
IN = [p(A), p(B)],
select(p(A), IN, OUT),
numbervars(IN, 0, _),
numbervars(OUT, 0, _),
format('~w~w~n', ['IN is ', IN]),
format('~w~w~n', ['OUT is ', OUT]).
test8:-
IN = [p(A), p(B)],
between(1, 2, IND),
nth1(IND, IN, _, OUT),
numbervars(IN, 0, _),
numbervars(OUT, 0, _),
format('~w~w~n', ['IN is ', IN]),
format('~w~w~n', ['OUT is ', OUT]).
OUTPUT:
?- test7.
IN is [p(A),p(B)]
OUT is [p(B)]
true ;
IN is [p(A),p(A)]
OUT is [p(A)]
true.
?- test8.
IN is [p(A),p(B)]
OUT is [p(B)]
true ;
IN is [p(A),p(B)]
OUT is [p(A)]
true.