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.&nbsp; One use for it might be to write 
 > a predicate that determines if a term is ground.&nbsp; Notice that</div>
 > <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
 > <div><strong>local </strong>X <strong>in<br></strong>&nbsp;&nbsp; {Browse 
 > {IsDet p(X)}}<br><strong>end</strong></div></blockquote>
 > <div>yields true.&nbsp; 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>&nbsp;</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>&nbsp;</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> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" 
 > href="mailto:[EMAIL PROTECTED]" target="_blank">[EMAIL PROTECTED]
 > </a>&gt; 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.&nbsp; </div>
 > <div>&nbsp;</div>
 > <div>Thanks.</div>
 > <div>&nbsp;</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>&nbsp;</span></div>
 > <div><span>
 > <div><span class="gmail_quote">On 9/26/05, <b class="gmail_sendername">Peter 
 > Van Roy</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" 
 > href="mailto:[EMAIL PROTECTED]" target="_blank">[EMAIL PROTECTED]</a>
 >  &gt; 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>&gt; 
 > Prolog has a univ operator (=..) which constructs and deconstructs terms.<br>
 > &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; f(a, b, c) =.. [f, a, b, 
 > c]<br>&gt;<br>&gt; It works in either direction and unifies variables on 
 > either side as<br>&gt; long as the &quot;label&quot; is an 
 > atom.&nbsp;&nbsp;Is there anything like that in Oz?&nbsp;&nbsp;I<br>
 > &gt; haven't seen it.&nbsp;&nbsp;Neither* =..* nor *univ* is in the index of 
 > CTM.<br>&gt;<br>&gt; 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.&nbsp;&nbsp;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.&nbsp;&nbsp;These operations are used in<br>Prolog for particular 
 > programming techniques.&nbsp;&nbsp;In Oz there are 
 > <br>better ways.&nbsp;&nbsp;For example, dictionaries are almost always a 
 > better<br>primitive than assert or retract.&nbsp;&nbsp;Search engines are 
 > better than<br>setof or bagof.&nbsp;&nbsp;And so forth.<br><br>Oz is a 
 > descendant of AKL, which is a descendant of both 
 > <br>Prolog and Concurrent Prolog.&nbsp;&nbsp;Oz has taken the best of 
 > these<br>languages and left out the hacks.&nbsp;&nbsp;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

Reply via email to