Peter Van Roy wrote:
Rusreg wrote:
Hello.

The functions in list module are determinstic. For example I want to use the List.append function as nondeterministic for parsing string, but it don't work:

Str in
List = {List.append "(" Str}

I found the nondet. realization of this function in Internet:

proc {Append L1 L2 L3}
  dis L1=nil L2=L3
  [] X M1 M3 in
     L1=X|M1 L3=X|M3 {Append M1 L2 M3}
  end
end

and it work fine. Why the functions in List is deteministik? E.g. the same function (append) of Curry language is nondetermenistik.
Another point about nondeterministic functions: the use of 'dis' is deprecated in Mozart. You should use 'choice' instead. The reason has to do with Prolog-style versus constraint-style programming. Prolog programs basically do generate and test (enumerate and then prune). Constraint programs do pruning before enumeration (using propagators), which is more efficient. 'Dis' is a kind of poor man's way for Prolog programs to do a little bit of pruning, but it is a dead end since it is still in the Prolog style. If you really need nondeterminism (search) in a strong way, you should use the constraint style and not the Prolog style. If you need just a little bit of nondeterminism or if you are just exploring solutions in a simple way, you can use Prolog style. But Prolog style does not scale up to real problems.

Peter

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

Reply via email to