How about:
fun {IsGround V}
{Not {IsFree V}} andthen
case {Value.type V} of
record then
{Record.all V IsGround}
[] tuple then
{Record.all V IsGround}
[] _ then true
end
end
This assumes you are only interested in unbound variables in
records/tuples/lists. You can extend the example to dictionaries,
arrays etc. if required.
I don't think it is possible to create a record with an unbound
label. If so, then that must be added too ({IsDet {Record.label V}}).
cheers
k
Russ Abbott writes:
> It may be that it's not needed, but for my own amusement, would you show me
> how to implement univ in Oz. One use for it might be to write a predicate
> that determines if a term is ground. Notice that
>
> *local *X *in
> * {Browse {IsDet p(X)}}
> *end*
>
> yields true. How would one write a predicate *IsGround* that would return
> true or false depending on whether it's argument contained any unbound
> variables?
> -- Russ
> _____________________________________________
> Russ Abbott
> Professor, Computer Science
> California State University, Los Angeles
> o Check out my blog at http://russabbott.blogspot.com/
>
>
> On 9/26/05, Russ Abbott <[EMAIL PROTECTED]> wrote:
> >
> > It may be that it's not needed, but for my own amusement, would you show
> > me how to implement univ in Oz.
> > Thanks.
> > -- Russ
> > _____________________________________________
> > Russ Abbott
> > Professor, Computer Science
> > California State University, Los Angeles
> > o Check out my blog at http://russabbott.blogspot.com/
> > On 9/26/05, Peter Van Roy <[EMAIL PROTECTED] > wrote:
> > >
> > > Russ Abbott wrote:
> > >
> > > > Prolog has a univ operator (=..) which constructs and deconstructs
> > > terms.
> > > >
> > > > f(a, b, c) =.. [f, a, b, c]
> > > >
> > > > It works in either direction and unifies variables on either side as
> > > > long as the "label" is an atom. Is there anything like that in Oz? I
> > > > haven't seen it. Neither* =..* nor *univ* is in the index of CTM.
> > > >
> > > > Thanks.
> > >
> > > Oz does not have =.. as a basic operator, but it can easily be defined.
> > > But =.. is almost never needed in practice. Oz has a much richer
> > > record data type that makes =.. superfluous.
> > >
> > > There are also good reasons why Oz does not have 'var' or '!' or
> > > assert or retract or setof or bagof. These operations are used in
> > > Prolog for particular programming techniques. In Oz there are
> > > better ways. For example, dictionaries are almost always a better
> > > primitive than assert or retract. Search engines are better than
> > > setof or bagof. And so forth.
> > >
> > > Oz is a descendant of AKL, which is a descendant of both
> > > Prolog and Concurrent Prolog. Oz has taken the best of these
> > > languages and left out the hacks. At least, that's my view!
> > >
> > > Peter
> > >
> >
> <div>It may be that it's not needed, but for my own amusement, would you
> show me how to implement univ in Oz. One use for it might be to write
> a predicate that determines if a term is ground. Notice that</div>
> <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
> <div><strong>local </strong>X <strong>in<br></strong> {Browse
> {IsDet p(X)}}<br><strong>end</strong></div></blockquote>
> <div>yields true. How would one write a predicate <em>IsGround</em>
> that would return true or false depending on whether it's argument contained
> any unbound variables?</div><span class="q">
> <div> </div>
> <div>-- Russ<br>_____________________________________________<br>Russ
> Abbott<br>Professor, Computer Science<br>California State University, Los
> Angeles<br>o Check out my blog at <a onclick="return
> top.js.OpenExtLink(window,event,this)"
> href="http://russabbott.blogspot.com/" target="_blank">
> http://russabbott.blogspot.com/</a> </div>
> <div><br><br> </div></span>
> <div><span class="e" id="q_106936bfb4561086_2">
> <div><span class="gmail_quote">On 9/26/05, <b class="gmail_sendername">Russ
> Abbott</b> <<a onclick="return top.js.OpenExtLink(window,event,this)"
> href="mailto:[EMAIL PROTECTED]" target="_blank">[EMAIL PROTECTED]
> </a>> wrote:</span>
> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px
> 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
> <div>It may be that it's not needed, but for my own amusement, would you
> show me how to implement univ in Oz. </div>
> <div> </div>
> <div>Thanks.</div>
> <div> </div>
> <div>-- Russ<span><br>_____________________________________________<br>Russ
> Abbott<br>Professor, Computer Science<br>California State University, Los
> Angeles<br>o Check out my blog at <a onclick="return
> top.js.OpenExtLink(window,event,this)"
> href="http://russabbott.blogspot.com/" target="_blank">
> http://russabbott.blogspot.com/</a> <br> </span></div>
> <div><span>
> <div><span class="gmail_quote">On 9/26/05, <b class="gmail_sendername">Peter
> Van Roy</b> <<a onclick="return top.js.OpenExtLink(window,event,this)"
> href="mailto:[EMAIL PROTECTED]" target="_blank">[EMAIL PROTECTED]</a>
> > wrote:</span>
> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px
> 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Russ Abbott wrote:<br><br>>
> Prolog has a univ operator (=..) which constructs and deconstructs terms.<br>
> ><br>> f(a, b, c) =.. [f, a, b,
> c]<br>><br>> It works in either direction and unifies variables on
> either side as<br>> long as the "label" is an
> atom. Is there anything like that in Oz? I<br>
> > haven't seen it. Neither* =..* nor *univ* is in the index of
> CTM.<br>><br>> Thanks.<br><br>Oz does not have =.. as a basic
> operator, but it can easily be defined.<br>But =.. is almost never needed in
> practice. Oz has a much richer
> <br>record data type that makes =.. superfluous.<br><br>There are also good
> reasons why Oz does not have 'var' or '!' or<br>assert or retract or setof
> or bagof. These operations are used in<br>Prolog for particular
> programming techniques. In Oz there are
> <br>better ways. For example, dictionaries are almost always a
> better<br>primitive than assert or retract. Search engines are
> better than<br>setof or bagof. And so forth.<br><br>Oz is a
> descendant of AKL, which is a descendant of both
> <br>Prolog and Concurrent Prolog. Oz has taken the best of
> these<br>languages and left out the hacks. At least, that's my
> view!<br><br>Peter<br></blockquote></div></span></div></blockquote></div></span></div>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users