0
votes

I've recently started learning Prolog and I've a question about predicates and functions. How can I write a function which will check if objects in a predicate is in another predicate For instance:

vertex(a).
edge(l,k,-1).
edge(k,l,4).
edge(a,z,-2).
checkEdges(edge(X,Y,_)) :- vertex(X),vertex(Y)

P.S How can I make this function to print a message if elements are not vertices?

1
This is not a function. Prolog has no functions, it only has predicates and functors.Willem Van Onsem

1 Answers

0
votes

Something like

checkEdges(edge(X,Y,_)) :-
  ( vertex(X), vertex(Y) ->
    true
  ; write('not vertices'),nl ).

?