Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 49:43:05 |
Calls: | 583 |
Files: | 1,138 |
Messages: | 111,301 |
Concerning the input (xxx yyy zzz) the OP wrote:
I would expect it to print zzz(xxx(yyy)).
Where did he get this requirement from, he didnrCOt
compare other Prolog systems, right? So it came from
his applicationdomain. But what was his application
domain? Ok, lets proceed to an example with multiple
brakets. Lets make the Pascal rCLbeginrCY rCLendrCY example,
by replacing xxx and zzz by rCLbeginrCY and rCLendrCY.
I get this result:
?- member(X,[begin,end]), current_op(Y,Z,X).
X = (begin), Y = 1100, Z = fy ;
X = (end), Y = 1100, Z = yf.
?- X = (begin
|-a-a-a-a-a-a-a-a-a x = 1;
|-a-a-a-a-a-a-a-a-a y = 2;
|-a-a-a-a-a-a-a-a-a begin
|-a-a-a-a-a-a-a-a-a-a-a-a-a-a z = 3
|-a-a-a-a-a-a-a-a-a end
|-a-a-a-a-a-a end).
X = (begin x=1;y=2;begin z=3 end end).
But is the abstract parse term, the Prolog result useful?
Take this test case:
test1(X) :- X = f(g(X,_B),_A).
test2(X) :- Y = g(f(Y,A),_B), X = f(Y,A).
Now try this (numbervars/3):
/* SWI-Prolog 9.3.26 */
?- test1(X), numbervars(X,0,_).
X = f(g(X, A), B).
?- test2(X), numbervars(X,0,_).
X = f(_S1, A), % where
-a-a-a _S1 = g(f(_S1, A), B).
And try this (nonground/2):
?- test1(X), nonground(X, V).
X = f(g(X, V), _).
?- test2(X), nonground(X, V).
X = f(_S1, V), % where
-a-a-a _S1 = g(f(_S1, V), _).
And try this (term_variables/2):
?- test1(X), term_variables(X, [V,W]).
X = f(g(X, V), W).
?- test2(X), term_variables(X, [V,W]).
X = f(_S1, V), % where
-a-a-a _S1 = g(f(_S1, V), W).
All 3 predicates suffer from an similar anomaly,
namely, in the first query V appears 2nd
argument of g/2, and in the second query V
appears 2nd argument of f/2. Can this be fixed?
Mild Shock schrieb:
Concerning the input (xxx yyy zzz) the OP wrote:
I would expect it to print zzz(xxx(yyy)).
Where did he get this requirement from, he didnrCOt
compare other Prolog systems, right? So it came from
his applicationdomain. But what was his application
domain? Ok, lets proceed to an example with multiple
brakets. Lets make the Pascal rCLbeginrCY rCLendrCY example,
by replacing xxx and zzz by rCLbeginrCY and rCLendrCY.
I get this result:
?- member(X,[begin,end]), current_op(Y,Z,X).
X = (begin), Y = 1100, Z = fy ;
X = (end), Y = 1100, Z = yf.
?- X = (begin
|-a-a-a-a-a-a-a-a-a x = 1;
|-a-a-a-a-a-a-a-a-a y = 2;
|-a-a-a-a-a-a-a-a-a begin
|-a-a-a-a-a-a-a-a-a-a-a-a-a-a z = 3
|-a-a-a-a-a-a-a-a-a end
|-a-a-a-a-a-a end).
X = (begin x=1;y=2;begin z=3 end end).
But is the abstract parse term, the Prolog result useful?