When a dict method has more solutions and I put the method call in a lambda then the lambda definition has more solutions

When I write:

:- module( dict_test, [create/1, test_004/1, test_005/1]).

create( DT) :- DT = dict_test{ a:[1,2]}.

M.iter1() := VALUE :- member( VALUE, M.a).


test_004(RES) :- true
, create( M)
, TERM = [VALUE] >> ( VALUE = M.iter1() ) % iterations starting from here
, writeln( 1)
, findall( VALUE, call( TERM, VALUE), RES)
.

lambda(M, VALUE) :- VALUE = M.iter1().

test_005(RES) :- true
, create( M)
, TERM = [VALUE] >> ( lambda(M, VALUE) ) % iterations starting from here
, writeln( 1)
, findall( VALUE, call( TERM, VALUE), RES)
.


And then call:

?- test_004(X).
1
X = [1] ;
1
X = [2].

Then this is not intended.

If I took the lambda code in a predicate it would work.

?- test_005(X).
1
X = [1, 2].

Besides using an extra predicate how can I fix thix?

This seems to work:


test_006(RES) :- true
, create( M)
, TERM_ = '.'(M, iter1(), VALUE)
, writeln( 1)
, TERM = [VALUE] >> ( TERM_ )
, findall( VALUE, call( TERM, VALUE), RES)
.