1

I am trying to create a list of pairs which have a non-null Guard element.

get_only_guarded(L) :-
    Guard \= null,
    findall([S,D],transition(S,D,_,Guard,_),L).

This is what ive tried but it doesnt seem to work. What would be the correct way?

mat
  • 40,498
  • 3
  • 51
  • 78

2 Answers2

3

Use dif(Guard,null) instead. Handle (\=)/2 with care!

repeat
  • 18,496
  • 4
  • 54
  • 166
2

a more 'conventional ' way to do: push the test after the instantiation

get_only_guarded(L) :-
    findall([S,D], (transition(S,D,_,Guard,_),Guard \= null), L).
CapelliC
  • 59,646
  • 5
  • 47
  • 90