Quoting Russ Abbott <[EMAIL PROTECTED]>:
> I guess that's to be expected, but shouldn't SearchAll suppress that? Isn't
> that sort of thing how SearchAll knows to stop?
SearchAll is supposed to handle logic failure not programming errors. Ok,
sometimes it is hard to tell one from the other, but that is not your case.
List syntax in Oz is like this: E1|E2|...|Tail , i.e.
(Prolog) [H|T] = H|T (Oz)
(Prolog) [E1, E2, E3, ..., E4] = [E1 E2 E3 ... E4] (Oz)
And as far as IsMember goes:
proc {IsMember X L}
H|T = L in % If L is empty, this will fail (which is expected)
choice X = H [] {IsMember X T} end
end
Cheers,
Jorge.
> When I added 'else skip' to my case statement, I got [1 2 3 4 5 _], which
> is not what one wants.
> I guess that could be fixed with some ugly coding, matching to X1 X2 | Tail
> in one case and [X1] in the other. But one shouldn't have to do that.
> This, finally, works.
>
> local
> proc {IsMember X Xs}
> case Xs of H1 | (H2 | Tail) then
> choice H1 = X [] {IsMember X H2 | Tail} end
> [] [H] then X = H
> end
> end
> in
> {Browse {SearchAll proc {$ Y} {IsMember Y [1 2 3 4 5]} end}}
> end
>
> -- Russ
> P.S. In the course of getting this to run I found out that H1 H2 | Tail is
> not valid syntax as the equivalent is in Prolog. It doesn't work with
> parentheses either: (H1 H2 | Tail)
>
> On 10/3/05, Russ Abbott <[EMAIL PROTECTED]> wrote:
>
> > I'm still trying to use Oz like Prolog, and I'm still confused. For
> > example, I was hoping that if X is unbound the following would bind it to
> > elements of Xs.
> >
> > proc {IsMember X Xs}
> > case Xs of
> > Head | Tail then
> > choice
> > Head = X
> > [] {IsMember X Tail}
> > end
> > end
> > end
> > If I run
> > {IsMember Y [1 2 3 4 5]}
> > {Browse Y}
> > Ozcar tells me that I get to the 'end' at the bottom of the choice
> > statement with X bound to 1. At that point the thread turns yellow, saying
> > that it is running. What is it waiting for?
> > If instead I run
> >
> > {Browse {SearchAll proc {$ Y} {IsMember Y [1 2 3 4 5]} end}}
> > the thread turns yellow when it enters SearchAll. Why don't I get all
> > members of the list as the SearchAll answer?
> > Thanks.
> > -- Russ
> >
>
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users