[racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.

From: WarGrey Gyoudmon Ju (juzhenliang at gmail.com)
Date: Thu Jul 3 00:48:13 EDT 2014

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140703/973fa385/attachment.html>

Posted on the users mailing list.