【发布时间】:2012-07-26 14:09:03
【问题描述】:
我正在尝试编写一个 Prolog 脚本,该脚本可以创建一个字符串列表,在简单的过程之后会生成一个给定的字符串。我对 Prolog 的了解非常有限,我什至不确定它是否能够执行此操作,所以请告诉我是否不可能。
到现在为止
replace_word(Old, New, Orig, Replaced) :-
atomic_list_concat(Split, Old, Orig),
atomic_list_concat(Split, New, Replaced).
它可以执行这个操作
10 ?- replace_word('a','e','glava',X).
X = gleve.
但它不能回溯它
11 ?- replace_word('a','e',X,'gleve').
ERROR: atomic_list_concat/3: Arguments are not sufficiently instantiated
我可以想象是什么导致了这个问题,但是有没有办法解决它?
【问题讨论】:
标签: prolog swi-prolog instantiation-error