From 32c9ea680f87bdde5d8fd0e40dc155979e1e054b Mon Sep 17 00:00:00 2001 From: Caspar Safarlou Date: Fri, 14 Nov 2014 15:17:51 +0100 Subject: [PATCH] isHittingTree(tree) uitgewerkt --- pl-files/hittingSetTree.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pl-files/hittingSetTree.pl 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 -- 2.20.1