Reputation: 41
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
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