0

i am quite new to prolog and i'd like an explanation about something if possible.

What exactly does the

"-->"

prolog operator do? i can't seem to find an easy straight answer for that.

and just one more thing...

what's the difference between:

    phrase--> noun(X),
verb(X).

and this

phrase:- noun(X),
verb(X).

thanks in advance!

Guy Coder
  • 24,501
  • 8
  • 71
  • 136

2 Answers2

1

Prolog supports a notation for Definite Clause Grammars. The --> is actually short hand for a more elaborate predicate. If you enter this:

foo --> noun(X), verb(X).

And then do a listing, you'll see something like this this:

foo(A, B) :-
   noun(X, A, D),
   verb(X, D, B).

See here, for example: Grammars in Prolog

The shorthand makes it easier to express grammars in Prolog more clearly.

lurker
  • 56,987
  • 9
  • 69
  • 103
0

It's used for syntax analysis. You should read this paper about DCG in Prolog

nouney
  • 4,363
  • 19
  • 31