1
votes

When i do an assert like:

assert(-color(red)).

it gives me the error:

ERROR: assert/1: No permission to modify static procedure `(-)/1'

so i change -color to dynamic:

dynamic -color/4.

and now it gives me the error:

ERROR: dynamic/1: Type error: `atom' expected, found `-color'

Any ideas?

1

1 Answers

5
votes

First off, as Prolog itself is telling you, it is reading -color(foo) as -(color(foo)). That's why it's complaining about (-)/1 and not -color. You cannot begin an atom with a hyphen.

Second, you want asserta/1 or assertz/1, not assert/1.

Third, when you declare a dynamic predicate with arity 4, you should use it with arity 4, not arity 1. In other words, your dynamic should either read :- dynamic color/4 and be used asserta(color(Red,Green,Blue,Alpha)) or it should read :- dynamic color/1 and be used asserta(color(red)). The combination /4 with /1 is not what you mean.