subtrees([]).
subtrees([(Cost,T)|Rest]) :−
number(Cost),
istree(T),
subtrees(Rest).
istree(tree(_,Children)) :− subtrees(Children).
dfs(GoalValue,tree(GoalValue,_),GoalValue,0).
dfs(GoalValue,tree(Value,[(Cost,T)|Rest]),Path,FinalCost) :−
T = tree(IV,_),
write(IV ),
dfs(GoalValue, T,P,C),
string_concat(Value,P,Path),
FinalCost is C+Cost
; % go down one depth level
dfs(GoalValue,tree(Value,Rest),Path,FinalCost). % next child
Can someone help me understand this Prolog implementation of Depth First Search? A subpart of my question also includes how to interpret splitting within the Head part.
subtrees([(Cost,T)|Rest])
I am aware that each list is considered [Heads|Tails], but how does one interpret (Cost, T )? Is it a 2D list?