[plt-scheme] Re: plt-scheme Digest, Vol 5, Issue 14
On Fri, 2006-01-06 at 08:40 -0800, geb a wrote:
. . .
> This is where I have troubles... How do you add a rule
> that John likes anything that Mary likes. At this
> point Schelog seems to lock up because the rule is
> recursive.
>
> ;John likes anything that Mary likes
> (%assert %likes ()
> [('john (which (stuff) (%likes 'mary stuff)))])
>
> What would the proper way to do this?
This is a SWAG -- I've just read through the schelog doc but I haven't
gotten it installed yet: I *think* the form would be
(%assert %likes (stuff)
[('john stuff) (%likes 'mary stuff)])
It appears you have to "declare" what variables you're using in a
particular %rel or %assert form, which is why "(stuff)" is the third
subform of the %assert. The forms in brackets contain the head of the
clause followed by the goals making up the body. So the form in
brackets corresponds to the Prolog
"likes(john,Stuff) :- likes(mary,Stuff)."
The definition of "%member" at the top of Section 3 of the schelog doc
shows the pattern for defining a recursive predicate.
I'm finding the separation of the functor from the args of the clause
head unnerving. This syntax seems almost to be an intermediate form a
compiler might build after finding all the clauses for a given
functor/arity pair. But hey, we lispers are happy with S expressions,
which were originally intended to be essentially ASTs for a more
conventional surface syntax.
-- Bill Wood