users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DCG question: bind to inputs.


From: Alexandre Saidi
Subject: Re: DCG question: bind to inputs.
Date: Tue, 30 Jul 2013 13:46:36 +0200
User-agent: Internet Messaging Program (IMP) H3 (4.3.5)

Dear Sean,
As long as I remeber when I used to do DCG is that you must put your own Prolog Clause for that :

foo(X,In, Out) :- ....

If ever your DCG rule is :
foo(X) --> [C], bar(X, ...), {format(...)}.

then you can write :
foo(X, [C | Cs_temp ], Cs) :- bar(X, Cs_temp, Cs), format(....).

DCG accepts that you insert your own Prolog predicates.

Alex

emacstheviking <address@hidden> a écrit :

Hi,

After reading the manual (section 7.17.1 again) I am still confused... If I
have this DCG rule:

foo(X) --> bar(X)

I know it expands to:

foo(X,A,B) :- bar(X, A, B).

How do I add a format statement like this:

foo(X) --> bar(X), {format("bar(X) ok, X is ~w~n", [???])}.

How do I bind to those two input arguments that are the source list and the
resulting output list so I can do things with them / to them ? Sure I can
print out X because that is in scope as it were but how to get A and B ?? I
know this is a simple question and even worse I know I think I already know
the answer, I just don't know I know yet.

Thanks,
Sean.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]