From: Caspar Safarlou Date: Fri, 14 Nov 2014 14:17:51 +0000 (+0100) Subject: isHittingTree(tree) uitgewerkt X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=32c9ea680f87bdde5d8fd0e40dc155979e1e054b;p=ker1415-1.git isHittingTree(tree) uitgewerkt --- diff --git a/pl-files/hittingSetTree.pl b/pl-files/hittingSetTree.pl new file mode 100644 index 0000000..925447c --- /dev/null +++ b/pl-files/hittingSetTree.pl @@ -0,0 +1,13 @@ +:- [diagnosis]. + +isHittingSetTree(Tree) :- + isHittingSetTree2(Tree, []). %function to add variable for uniqueness checking + +isHittingSetTree2(leaf, _). %when end of branch has been reached +isHittingSetTree2(node([], []), _). %when a node turns empty +isHittingSetTree2(node([X|Xs], [Y|Ys]), Z) :- + not(member(X,Z)), %check if label has already been used up in the tree + append(Z, [X], Appended), %append label to list of checked labels + isHittingSetTree2(Y, Appended), %go into depth + isHittingSetTree2(node(Xs, Ys), Z). %go into width + \ No newline at end of file