我是序言中的新手,我想知道是否有一种方法可以替换像这样描述的元素的一部分:
S = ( tab/field = 2 ), (X/Y=V)=S.
S = ( +field > 2 ), (+Y>V)=S.
在以下示例中,我想替换表达式的一部分(X和Y部分),但保留运算符,就像这样:
( replacedValue = 2)
( replacedValue > 2)
感谢您的帮助
答案 0 :(得分:1)
?- S = (tab/field = 2), display(S), S =.. [Op, L, R], Result =.. [Op, replaced, R].
=(/(tab,field),2)
S = (tab/field=2),
Op = (=),
L = tab/field,
R = 2,
Result = (replaced=2).
?- S = (+field > 2), display(S), S =.. [Op, L, R], Result =.. [Op, replaced, R].
>(+(field),2)
S = (+field>2),
Op = (>),
L = +field,
R = 2,
Result = (replaced>2).