What is the difference between _ and _variable in prolog?

I ran into a lot of problems with a literal that starts with _ , like _Peter . So what will be the difference between:

good(_,_).

and

good(_,_Peter).

Thanks for answering my question!

+6
source share
1 answer

_ is an anonymous variable. Multiple occurrences in the same sentence (or the same term) represent different variables.

A variable starting with _ but containing extra characters is not an anonymous variable. Multiple occurrences represent the same variable.

By convention, many Prolog systems require that variables that have only one time must begin with _ . But this is the convention leading to warnings in most implementations.

+9
source

Source: https://habr.com/ru/post/989028/


All Articles