lam5442
lam5442

Reputation: 41

Creating a list from a from a set of atoms in Prolog

Eventually, I will need to create a list of lists in Prolog, but currently, I am having difficulty taking atoms and creating an initial list. I have a cat predicate whose will take in the cat's color and breed. The name of the cat will represent the name of the list. For example:

fluffy[white, persian]

dante[gray, russian_blue]

I have tried to use the following code to create the first list, but I always get a compilation error:

cat([Color, Breed], Name(Color, Breed), Name).

The error tells me I need a , or a (.

Any thoughts on what I am doing wrong?

Upvotes: 1

Views: 345

Answers (1)

Kaarel
Kaarel

Reputation: 10672

You get a syntax error because the name of a term must be an atom. I.e. in order to avoid the syntax error change Name(Color, Breed) e.g. to 'Name'(Color, Breed). This probably does not solve the semantic errors in your code though...

Upvotes: 1

Related Questions