[plt-scheme] Scheme Datalog
Hi,
I was looking to use datalog in a regular scheme program in the same
way you might use SQL from scheme:
e.g. (select ((pers first-name) (pers last-name)) (pers)) [scheme-pg-Z-G-33.gif]
The following is taken from the test, but I don't know how I would
integrate it with a scheme program. (I'm thinking of a program that
reads in a set of family trees and then can tell if two people are
related.) Can I just start asserting and querying like this?
(define PARENT "john")
(define CHILD 'billy)
(! (parent PARENT CHILD))
(? (parent PARENT CHILD))
;;
#lang scheme
(require (planet jaymccarthy/datalog:1:1/sexp))
(define test
#'(begin
(! (parent john douglas))
(? (parent john douglas))
(? (parent john ebbon))
(! (parent bob john))
(! (parent ebbon bob))
(? (parent ,A ,B))
(? (parent john ,B))
(? (parent ,A ,A))
(! (:- (ancestor ,A ,B)
(parent ,A ,B)))
(! (:- (ancestor ,A ,B)
(parent ,A ,C)
(ancestor ,C ,B)))
(? (ancestor ,A ,B))
(? (ancestor ,X john))
(~ (parent bob john))
(? (parent ,A ,B))
(? (ancestor ,A ,B))))
(stx->program test)
;;
Thanks,
Stephen
On Mon, Mar 23, 2009 at 1:50 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> There are some examples in the test suite:
>
> http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/1/tests/examples/
>
> I was getting a weird Scribble bug when I tried to document the s-exp
> language better, but you can look directly at some of the tests:
>
> http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/1/tests/sexp.ss
>
> That's the same program as
>
> http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/1/tests/examples/tutorial.ss
>
> Hopefully this is helpful?
>
> Jay
>
> On Mon, Mar 23, 2009 at 3:31 AM, Mark Engelberg
> <mark.engelberg at gmail.com> wrote:
>> Can anyone point me to some problems/exercises that are interesting to
>> solve using Datalog?
>> Are there any more complete examples of the S-expression version of
>> Datalog? The tutorial seems to mostly use the version where you parse
>> strings, and I'd like to see a couple S-expression examples to make
>> sure I'm understanding the grammar correctly.
>>
>> Thanks,
>>
>> Mark
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
>
> "The glory of God is Intelligence" - D&C 93
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>