[racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.
Yes, I corrected your program and ran into this bug.
Try to use Kanren instead of Racklog. It isn't completely a legacy package but I doubt we can get a quick fix here.
-- Matthias
On Jul 3, 2014, at 4:53 PM, WarGrey Gyoudmon Ju wrote:
> Sorry, my example is not correct.
> But this one still does not work:
>
> #lang at-exp racket
>
> (require racklog)
>
> (define %edge
> (%rel ()
> [('a 'b)]
> [('b 'c)]
> [('c 'd)]
> [('d 'a)]))
>
> (define %path
> (%rel (X Y Z)
> [(X Y) (%edge X Y)]
> [(X Y) (%edge X Z) (%path Z Y)]))
>
> (let answer ([r (%which (X Y) (%path X Y))])
> (printf "~a --> ~a~n" (cdar r) (cdadr r))
> (answer (%more)))
>
> This version also will not terminate.
>
> On Thu, Jul 3, 2014 at 9:04 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> If you want to learn Prolog, why not use a free Prolog implementation?
>
> Simply speaking, Modern Prolog seems to cut the illumos-based SunOS off, I cannot build it without headache and they does not answer me about this issue.
> So I wander if Racklog is a legacy package?
>
>
> If you want to learn about relational programming, use miniKanren, which is available of cKanren. Then you can also get to constraints. Maintainer cc-ed.
>
> -- Matthias
>
>
>
> On Jul 3, 2014, at 6:48 AM, WarGrey Gyoudmon Ju wrote:
>
> > This example is rewritten from the datalog version.
> >
> > #lang racket
> >
> > (require racklog)
> >
> > (define %edge
> > (%rel ()
> > [('a 'b)]
> > [('b 'c)]
> > [('c 'd)]
> > [('d 'a)]))
> >
> > (define %path
> > (%rel (X Y)
> > [(X Y) (%edge X Y)]
> > [(X Y) (%edge X 'Z)
> > (%path 'Z Y)]))
> >
> > (%find-all (X Y) (%path X Y))
> >
> > It only gives four results.
> >
> > #lang racklog
> >
> > edge(a, b).
> > edge(b, c).
> > edge(c, d).
> > edge(d, a).
> >
> > path(X, Y) :- edge(X, Y).
> > path(X, Y) :- edge(X, Z), path(Z, Y).
> >
> > path(X, Y)?
> >
> > and this version will not terminate.
> >
> > Thanks in advance.
> > ____________________
> > Racket Users list:
> > http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140703/8f605657/attachment.html>