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 didn’t
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 “begin” “end” example,
by replacing xxx and zzz by “begin” and “end”.
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
| x = 1;
| y = 2;
| begin
| z = 3
| end
| end).
X = (begin x=1;y=2;begin z=3 end end).
But is the abstract parse term, the Prolog result useful?
Yes, maybe, it depends. You would
need to fill in some logic for the
block functionality, like opening
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 didn’t
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 “begin” “end” example,
by replacing xxx and zzz by “begin” and “end”.
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
| x = 1;
| y = 2;
| begin
| z = 3
| end
| 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
_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
_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
_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 didn’t
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 “begin” “end” example,
by replacing xxx and zzz by “begin” and “end”.
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
| x = 1;
| y = 2;
| begin
| z = 3
| end
| end).
X = (begin x=1;y=2;begin z=3 end end).
But is the abstract parse term, the Prolog result useful?
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,066 |
Nodes: | 10 (0 / 10) |
Uptime: | 172:51:59 |
Calls: | 13,708 |
Calls today: | 2 |
Files: | 186,949 |
D/L today: |
7,939 files (2,202M bytes) |
Messages: | 2,415,905 |