Hi Chris,

I'll have to play with a little more, but it appears close to what I need - if nothing else it gave me some ideas of where I need to be looking. One thing I would like is for the retrieval of the items to be lazy - I may only want the first five choices retrieved. Since it's an infinite list of choices, don't want to get bogged down in retrieving the endless tail.


I think Raph's solution fits your needs.

Now, if you want to constrain the length of the list you can do it as follows:


declare
proc {Length02 L N}
   choice
      N=0
      L=nil
   [] T N2={FD.decl} in
      N=:N2+1
      L=_|T
      {Length02 T N2}
   end
end

{Browse {SearchAll proc {$ L}
                      % L is a list of at most 5 elements
                      N={FD.int 0#5}
                   in
                      L=1|2|_
                      {Length02 L N}
                   end}}

If you want to get the first 5 solutions only, then one alternative is the following:

declare
 SObj= {New Search.object script(proc {$ L}
                                   L=1|2|_
                                   {Length02 L {FD.decl}}
                                end)}

 %% Getting the first 5 solutions
 for I in 1..5 do
    {Browse {SObj next($)}}
 end

Luis

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

Reply via email to