"portray_clause" 
Author Message
 "portray_clause"

high all!

Quintus-PROLOG has a very useful built-in predicate called "portray_clause".
portray_clause is used e.g. by "listing" to pretty-print clauses. i defined
a new operator "<-" (behaves like :- but should be used in later extensions
to my own interpreter).  the  technical support of quintus told me that its
not possible  to use user-defined operators in portray_clause and that i'll
have to write my own portray_clause. so far, so good.  the problem is, that
i have  unbound variables in my clauses  and have to bind them to uppercase
ASCII-letters.  the  original portray_clause does that binding but it seems
that i could not use those internal routines. so my question is:
has anybody  written such a predicate  to bind all variables of a clause to
"A","B","C",...  (like the original portray_clause does)  and could send it
to me or do i have to develop something like that for myself...  :-(

              c u
                   tobias

---------------------------------------------------------------------------
Tobias Ruland, Dept. of Artificial Intelligence, University Erlan-

---------------------------------------------------------------------------



Fri, 02 Feb 1996 18:22:00 GMT  
 "portray_clause"

Quote:
> Quintus-PROLOG has a very useful built-in predicate called "portray_clause".
> portray_clause is used e.g. by "listing" to pretty-print clauses. i defined
> a new operator "<-" (behaves like :- but should be used in later extensions
> to my own interpreter).  the  technical support of quintus told me that its
> not possible  to use user-defined operators in portray_clause and that i'll
> have to write my own portray_clause. so far, so good.  the problem is, that
> i have  unbound variables in my clauses  and have to bind them to uppercase
> ASCII-letters.  the  original portray_clause does that binding but it seems
> that i could not use those internal routines. so my question is:
> has anybody  written such a predicate  to bind all variables of a clause to
> "A","B","C",...  (like the original portray_clause does)  and could send it
> to me or do i have to develop something like that for myself...  :-(

I like QP but it has, as builtins, several things which I reckon oughta be
offered as library code instead: "portray_clause" is one of them.  *Please*
will someone provide PD source of something equivalent?

Incidentally, QP portray_clause/1 gives names to Singleton variables,
which conflicts with QP recommended style:

    | ?- portray_clause( fred(_)).
    fred(A).

    yes
    | ?- [user].
    | fred(A).
    * Singleton variables, clause 1 of fred/1: A

A query to Prolog implementors: if there are irresistible performance gains
to be had from kernelising library code (append/3 is a *built-in* in QP3,
for heaven's sake), couldn't these be put in a kernelised pseudo-module,
and exported to the library module where they really oughta be defined?
Then we are free to use the builtin versions, or substitute our own.

*Don't* ask why I should want to provide my own implementation of append;
this is a matter of principle :-)

I dread to hear that append was kernelised so the compiler could special-case
it (hey, why not build-in naive reverse to improve those benchmarks? :-)

Paul S.
----


 |  .  __).  Keele University, Newcastle,    tel: +44 (0)782 583477 << NEW for
             Staffs ST5 5BG, ENGLAND         fax: +44 (0)782 713082     1993



Fri, 02 Feb 1996 22:14:03 GMT  
 "portray_clause"
Try numbervars/2 (might be numbervars/3 - I'm not sure).  This is documented.

        Jens.
--


---------------------------------+---------------------------------------------
As the air to a bird, or the sea to a fish, so is contempt to the contemptible.



Sun, 04 Feb 1996 03:40:47 GMT  
 "portray_clause"

Quote:

> the problem is, that i have unbound variables in my clauses
> and have to bind them to uppercase ASCII-letters.

portray_clause/1 does not really bind the variables to uppercase
letters. It just prints the variables as uppercase letters.
You can do this as well. You 'numbervars' the term and then 'write'
the term. Something like: "\+ \+ (numbervars(Term, 0, _), write(Term))"

For more details see the manual pages for numbervars/3
and write_term/[2,3].

I am sure someone has already mentioned this, but news
seems to be slow in getting to Quintus these days. I never
saw the original post, I saw only Paul's followup to it.

Anil Nair



Wed, 07 Feb 1996 00:44:22 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

2. BEGIN{want[]={"s1o", "s2o", "s2q", "s3q"}

3. Parsing ""D""?

4. "Fifth", "Forth", zai nar?

5. Ruby "finalize", "__del__"

6. beginners "let"/"random" question

7. ANNOUNCE: new "plus"- and "dash"-patches available for Tcl7.5a2/Tk4.1a2

8. Looking for "stdin", "stdout"

9. Hi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "Two") text1.sub!("@BLAH", "Two") print text0,"\n" print text1,"\n" produces thiHi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "T

10. Match "ab" in "abc", but not in "abd"

11. replace string AFTER "size","initial", "next"

12. Lack of "D Tests", "E Tests", and "L Tests" for Generics

 

 
Powered by phpBB® Forum Software