Re: defining operators with a result



Richard Szopa wrote:
First of all, thank you all for your answers.

I think that the solution proposed by Glenn Lieding doesn't really
solve my problem. Having to adapt every predicate to deal with the mton
structure won't make my code more compact or more readable. Also, I
would like to be able to use my notation in built-in predicates, like
for example reverse and so on.

On the other hand, GRIPS goes much too far for me--I realize that
Prolog uses relational notation and I'm quite happy with it. Also, I
find remaining understandable for the rest of Prolog programmers quite
important. ;-)

The idea of trying to add this sugar to Prolog came to me when I found
that I use [m..n] quite often in my pseudo-Prolog code, but when I
translate it into Prolog, it gets somehow more obscure.

Anyway, an additional question: how would one define in Prolog |, the
cons operator, if it wasn't built in the language and f one wanted it
work exactly as | works now in [Head|Tail]? Or, if one wanted to be
able to use the '@' sign in one's Prolog programs instead of '|'? Is
it possible?

Of course, hacking the source of the interpreter is not the kind of
answer I expect ;-)

I'm not sure this is the answer you're looking for either, but:
extending the syntax of a lisp-embedded prolog is trivial if you stick
with sexps, and Common Lisp has an extendible reader for your to define
your own own special syntax...

ACL has a good embedded Prolog

http://www.franz.com/support/documentation/8.0/doc/prolog.html

but the source of the Prolog from Peter Norvig's book PAIP is available
under a nice license

http://www.norvig.com/license.html

also Paul Graham's book On Lisp is free to download and describes a
lisp-embedded prolog

http://www.paulgraham.com/onlisptext.html

hth

Nick


-- Richard

.



Relevant Pages

  • Re: Sublists question
    ... I do not really get what the predicate means or does. ... >>helps just to write the predicate out clearly in natural language, ... >>then translate into Prolog. ... more as a functional programming language than as a logic ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... I think prolog offers so much freedom that one can build its own ... Both modules define a member/2 predicate, ... this leads to a name conflict. ... shaky ground as current module systems (look at the issues with e.g. ...
    (comp.lang.prolog)
  • Re: Prolog, memory management and memory leaks
    ... predicate is executed that solves constraint problem. ... In some circumstances, this server leaks memory. ... "Understanding Memory Management in Prolog ... There is not just one garbage collector in Prolog. ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... my experiment with oop and modules has almost reach a point ... On the other hand, when I came to Prolog as a logic programming language, I ... Consider the length/2 predicate. ... OO systems have much more complex built-in lookup rules. ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... We talked a bit about this on the Prolog standardization forums but is ... Both modules define a member/2 predicate, ... this leads to a name conflict. ... shaky ground as current module systems (look at the issues with e.g. ...
    (comp.lang.prolog)