0

I am trying to port this Prolog code to Datalog in Racket, using example at bottom of this page.

#lang datalog

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)?

pathall(X,X,[]).
pathall(X,Y,[X,Z|L]):- arc(X,Z),pathall(Z,Y,L).
pathall(a, d)?

But it is giving this error at [X,Z|L] on last line of code:

read: expected a `]' to close `['

How do I represent a list in Datalog? Thanks for your help.

rnso
  • 23,686
  • 25
  • 112
  • 234

1 Answers1

3

Datalog is a syntactic subset of Prolog.

In particular, compound terms such as lists are not supported in Datalog.

mat
  • 40,498
  • 3
  • 51
  • 78
  • So, it may be best to use Prolog iteself for such tasks. Any other Scheme that takes Prolog code? Or Haskell? – rnso Sep 13 '17 at 07:46
  • 3
    In the context of these questions, my personal recommendation is to use Prolog directly: It is a full-fledged programming language and also has a built-in database. Why not jump directly to the real thing? – mat Sep 13 '17 at 08:26