How do I get a predicate in prolog to return a value?
I need to find a node of a tree and also check if its a min heap or not. I'm guessing it goes something like this:-
getnode(tree(_, node, _), node).
My code so far is this
minheap(tree(L, Node, empty)) :-
getnode(L, Val),
Node =< Val,
minheap(L).
minheap(tree(empty, Node, R)) :-
getnode(R, Val),
Node =< Val,
minheap(R).
getnode(tree(_,n,_) , n).
Input is of the type-
minheap(tree(empty,3,tree(tree(empty,8,empty),5,tree(empty,7,empty)))).
Output should be true.