-
With the code below, entering :- use_module(library(dcgs)).
demo1 -->
"start ",
"middle",
" end".
demo2 -->
"start ",
[Var],
" end",
{
Var = "middle"
}. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In
Note that you only see the loop, if you ask for the next answer. Whereas
works as expected. To understand all of this, you need to master the notion of a failure slice. In this case, it would be demo3 --> "start ", seq(Middle), {false}, Now the following holds: If this failure slice does not terminate, then also your original program does not terminate (although it might still produce an answer here and there). |
Beta Was this translation helpful? Give feedback.
In
demo2//0
there is place for only a single character/term. If you want to include an arbitrary sequence, useseq//1
. But beware, you are now having a definition that may not terminate! In fact:Note that you only see the loop, if you ask for the next answer.
Whereas
works as expected. To understand all of this, you need to master the notion of a failure slice. In this case, it would be