Yes, the cell's value is logically "backtracked" as well as everything
else when you reach the second choice. This is because "choice"
creates computational spaces, try reading chapter 12 of the language
tutorial.
Oh, wow! You can backtrack an... assignment!?!?
Yes :-)
OK, so how would you actually approach this problem then??
I'd have thought that some kind of state would be the way to go, at
least for something non-concurrent. (I had also tried using a global
dictionary, using the parse level as the key, but the system kicked it
out saying I couldn't set a global value from a local procedure, or some
such. Fair enough, but what are the options?)
I'd really be curious to see the elegant Oz solution to this, which,
after all, is a reasonable simulation of a real-world spec!
I'm an Oz newbie myself, but I'll try to explain. The purpose of the
choice statement is to express the non-deterministic decision in the
search tree. But what you are trying to do is *enforce* one of the (two)
branches. You can not use "choice" for that.
The solution to your problem depends on the complexity of the Corresp
procedure. If it is really non-deterministic (it uses choice or some
kind of distribution step, like FD.distribute), you might need to
construct a nested search to see if the {Corresp First Word} statement
really succeeds, and act correspondingly in the main script.
...
Words = Word|WList
{Splitter First Rest NumberStr}
local
fun {CorrespScript First Word}
proc {$ Root}
Root=.....
{Corresp Root First Word}
end
end
in
CorrespSucceeded = ({SearchOne {CorrespScript First Word}} \= nil)
end
if {Not CorrespSucceeded} then
% there was no word, use the single digit
{Length First 1}
First = Word
CurrIsNum = true
else
CurrIsNum = false
end
...
You must pay special attention to which variables belong to the main
search and which belong to the nested search - you must not constrain
variables of the outer search inside the nested search. Also, if you
want the result to be reflected in the main search's variables, you must
do so explicitly using the result returned by SearchOne.
Hope this helps,
Filip
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users