Ellipticat
Ellipticat

Reputation: 198

Yap Prolog - List

I have this example of List in Prolog:

list_where([Tequila,Whisky,Vodka],bathroom).
list_where([Martini,Musat],kitchen).
list_where([Malibu,Soho],under_the_bed).
list_where([Epita],everywhere).

Now, I consult the file in yap (I'm using YAP on Ubuntu 15.10), and I launch this query:

list_where(X,bathroom).

I have this result:

X = [_A,_B,_C] instead of X=[Tequila,Whisky,Vodka]

How can i resolve this problem ?

Upvotes: 1

Views: 124

Answers (1)

lurker
lurker

Reputation: 58254

An identifier beginning with a capital letter in Prolog is a variable, not an atom. So

[Tequila, Whisky, Vodka]

is a list of variables. Therefore, when you query list_where(X, bathroom) you are getting back a list of uninstantiated variables, which YAP Prolog displays as [_A,_B,_C].

If you want capitalized atoms, use single quotes:

['Tequila', 'Whisky', 'Vodka']

Or, use lower case:

[tequila, whisky, vodka]

Upvotes: 3

Related Questions