I have tried so many things but I could not found How I can implement following wish in prolog .
if list is empty
call foo function
else
do nothing
What I did:
list = [] -> foo(...)
;
fail.
But, it does not work
faildoes not mean “do nothing”, but “fail (and backtrack)”.You need to use
trueinstead:Also,
Listshould be a variable, so use upper case.