In the following, either of the first two constraints work, but the third one doesn't. local
   fun {Plus2 X Y} X + Y end
   proc {Plus3 X Y Z} X + Y =: Z end
   proc {Test Answer}
      A B
   in
      Answer= [A B]
      Answer ::: 1#9
%      A + B =: 5            % OK
%      {Plus3 A B 5}        % OK
%      {Plus2 A B} =: 5    % Not OK
      {FD.distribute ff Answer}
   end
in
   {Browse {SearchAll Test}}
end

Hi Russ,

I think that if you replace Plus2 with

   fun {Plus2 X Y}
      Z={FD.decl}
   in
      X + Y =: Z
      Z
   end

you'll have what you wanted, and it even makes some sense :-) However, it is surely less effective than the "direct" version Plus3.

Note the difference between the two Plus2: my "X+Y" is not an expression to be returned from Plus2 (which is blocks as long as either X or Y are unknown) - it is rather a pattern "_ + _ =: _", which is translated by the compiler to {FD.sum [X Y] '=:' Z} - a statement rather an expression, in fact a propagator that constrains Z (the result) to be X+Y.

Cheers,
Filip
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to