我这样做是为了模拟全局变量:
update_queue(NewItem) :- global_queue(Q), retractall(global_queue(Q)), append(Q, [NewItem], NewQ), assert(global_queue(NewQ)).
还有另外一种方法吗?(除了将变量作为参数传递之外).不一定更有效率,我只是好奇.
global-variables prolog swi-prolog dcg prolog-assert
dcg ×1
global-variables ×1
prolog ×1
prolog-assert ×1
swi-prolog ×1