You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that you explained this concept in the procedural sense but not the logical one (or did I miss it?). A logical explanation would explain the concept better.
terms <tt>T<sub>1</sub>, ..., T<sub>n</sub></tt> to the remaining list.
For example:
<pre>
nt1, <b>[b]</b> --> [a].
nt2 --> [b].
</pre>
The body of <tt>nt1//0</tt> describes a list whose single element
Head, [T1,...,Tn] --> Body.
can be read operationally as: parse the list using Body, then prepend the terms T1, ..., Tn to the remaining list...
Would it be accurate to say that:
Head describes the list difference Body minus [T1, ..., Tn] ?
I was expecting you to write something like that.
Continuing the above:
nt1, [b] --> [a].
The body of nt1//0 describes a list whose single element is the atom a. Operationally, after nt1//0 has consumed the atom a in a list that is being parsed, it inserts the atom b in front of the remaining list.
If my statement above is correct, then I suppose that a more concise version of the previous sentence could be:
nt1 describes the list difference [a] - [b]
which is proven by the output:
?- phrase(nt1, A, B), list_diff(A, B) = list_diff([a], [b]).
A = [a],
B = [b].
Side note: We could add that using phrases like "X is the list difference Y - Z" would make it obvious to the newbie why phrase/3 is needed instead of phrase/2.
If I think of nt1 in this way, it helped me to understand the section about passing implicit states. E.g you write:
state(S0, S), [S] --> [S0].
The nonterminal state(S0, S) can be read as: "The current state is S0, and henceforth it is S".
That left me scratch my head! Instead, I was expecting something like:
state(S0, S) describes the list difference [S0] - [S] where the current state is S0 followed by the state S
I practised and learnt that we can make the list track all state changes by making a simple change:
% keep the S to maintain a historystate(S0, S), [S] --> [S0, S].
I understood that this works because it describes the list difference [S0, S] - [S] equalling [S0], describing only the expected current state S0.
What do you think of my logical description of pushback lists?
The text was updated successfully, but these errors were encountered:
I see that you explained this concept in the procedural sense but not the logical one (or did I miss it?). A logical explanation would explain the concept better.
Here, you write:
the-power-of-prolog/prolog/dcg.html
Lines 505 to 518 in d69a239
Would it be accurate to say that:
I was expecting you to write something like that.
Continuing the above:
If my statement above is correct, then I suppose that a more concise version of the previous sentence could be:
which is proven by the output:
If I think of nt1 in this way, it helped me to understand the section about passing implicit states. E.g you write:
That left me scratch my head! Instead, I was expecting something like:
I practised and learnt that we can make the list track all state changes by making a simple change:
I understood that this works because it describes the list difference
[S0, S] - [S]
equalling[S0]
, describing only the expected current stateS0
.What do you think of my logical description of pushback lists?
The text was updated successfully, but these errors were encountered: