如何等待直到在prolog中声明一个术语?
问题描述:
我想让我的一个prolog程序在线程2中运行。当我在主线程中声明某些内容时,线程2中的程序将监视该断言并相应地执行不同的事情。我怎样才能做到这一点?如何等待直到在prolog中声明一个术语?
我写这样的东西,但它真的很糟糕,因为它需要很多的CPU!
read_action(Act) :-
open('action.txt', read, Stream),
(can(go_next) ->
read_line_to_codes(Stream, Act),
write(Act),
close(Stream)
;
close(Stream),
read_action(Act)),
retractall(can(_)).
我使用Swipl
线程模型是实现定义的。你应该说明你正在使用的Prolog。 – CapelliC 2013-03-08 15:43:01