Prolog理解setof / 3带有^标记

问题描述 投票:0回答:1

有人可以向我解释这是什么吗?

(\+ setof((P1,C),P^R^Bag,PS) -> ...
otherwise ->...

我已经阅读了setof的文档;我的理解是,最主要的论点与事实相统一。

但是,我无法理解上面的代码段。

完整的代码段是:


solve_task_bt(go(Target),Agenda,ClosedSet,F,G,NewPos,RR,BackPath) :-
  Agenda = [Current|Rest],
  Current = [c(F,G,P)|RPath],
  NewAgenda = Rest,
  Bag = search(P,P1,R,C),
  (\+ setof((P1,C),P^R^Bag,PS) -> solve_task_bt(go(Target),Rest,[Current|ClosedSet],F,G,NewPos,RR,BackPath);
    otherwise -> 
    setof((P1,C),P^R^Bag,PS),
    addChildren(PS,RPath,Current,NewAgenda,Target,Result),
    NewClosedSet = [Current|ClosedSet],
    NewestAgenda = Result,
    solve_task_bt(go(Target),NewestAgenda,NewClosedSet,F1,G1,Pos,P|RPath,BackPath)
    ).  % backtrack search

prolog prolog-setof
1个回答
1
投票

所以,只关注setof/3

© www.soinside.com 2019 - 2024. All rights reserved.