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

后端 未结 1 1324
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 03:29

When i do an assert like:

assert(-color(red)).

it gives me the error:

ERROR: assert/1: No permission to modify static proce         


        
相关标签:
1条回答
  • 2020-12-22 04:15

    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.

    0 讨论(0)
提交回复
热议问题