What is English variable in English?

Asked

Viewed 1,151 times

2

I’m doing a job on Prolog and when trying to make a query it says there are "Singleton variables". For example, a part of the code:

s([Policia_X, Policia_Y, Ladrao_X, Ladrao_Y]) :- pode_andar_horizontal([Policia_X, Policia_Y]).

Returns the error:

Warning: c:/users/Leila/desktop/2018.2/ia/ia/trab1.pl:35: Singleton variables: [Ladrao_x,Ladrao_y]

What does that mean?

1 answer

2


This is a warning to help you with two common mistakes:

  • Spelling errors in variables
  • A variable not being used

Therefore, in your specific case, that warning says that in the file trab1.pl, on the line 35 (which is the:35), may be using variables that were no longer used in that rule or fact. It may also mean a spelling error. In the case of using the variable only once, for example:

teste(A): - t(B, A).

In this case, you can get rid of the warning message by placing the (_) the front of the variable Singleton, in this case the variable B:

teste(A): - t(_B, A).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.