无权修改静态过程`(-)/1' [英] No permission to modify static procedure `(-)/1'

查看:124
本文介绍了无权修改静态过程`(-)/1'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做如下断言时:

assert(-color(red)).

它给了我错误:

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

所以我将 -color 更改为动态:

so i change -color to dynamic:

dynamic -color/4.

现在它给了我错误:

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

有什么想法吗?

推荐答案

首先,正如 Prolog 本身告诉你的那样,它正在将 -color(foo) 读作 -(color(foo)).这就是为什么它抱怨 (-)/1 而不是 -color.原子不能以连字符开头.

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.

其次,您需要 assert/1assertz/1,而不是 assert/1.

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

第三,当你声明一个 arity 4 的动态谓词时,你应该使用它的 arity 4,而不是 arity 1.换句话说,你的动态应该读取 :- dynamic color/4 和使用 asserta(color(Red,Green,Blue,Alpha)) 或者它应该读取 :- dynamic color/1 并使用 asserta(color(red))./4/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.

这篇关于无权修改静态过程`(-)/1'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆