如何在列表中添加实例?
我正在使用 CLIPS,但在尝试在空列表中添加实例时遇到了麻烦。我正在使用 insert$ 函数,但似乎无法正常工作。具体代码是这样的:
(loop-for-count (?i 1 (length$ ?listaConvocatoriasAlumno))
(if (neq (nth$ ?i ?listaConvocatoriasAlumno) ?convocatoria)
then
(if (eq (str-compare (send (instance-address * (nth$ ?i ?listaConvocatoriasAlumno)) get-cuadrimestre) ?cuadrimestre) 0)
then
(insert$ ?listaConvocatoriasMismoCuadrimestre (+ (length$ ?listaConvocatoriasMismoCuadrimestre) 1) (nth$ ?i ?listaConvocatoriasAlumno))
)
)
)
?listaConvocatoriasAlumno 包含某个类的多个实例,我想将其中一些实例添加到另一个列表中(在本例中为 ?listaConvocatoriasMismoCuadrimestre ),该列表在循环开始时为空。
有什么想法吗?
预先非常感谢您!
I'm working with CLIPS and I'm getting in trouble when trying to add instances in an empty list. I'm using the insert$ function but does not seem to work properly. The concrete code is this:
(loop-for-count (?i 1 (length$ ?listaConvocatoriasAlumno))
(if (neq (nth$ ?i ?listaConvocatoriasAlumno) ?convocatoria)
then
(if (eq (str-compare (send (instance-address * (nth$ ?i ?listaConvocatoriasAlumno)) get-cuadrimestre) ?cuadrimestre) 0)
then
(insert$ ?listaConvocatoriasMismoCuadrimestre (+ (length$ ?listaConvocatoriasMismoCuadrimestre) 1) (nth$ ?i ?listaConvocatoriasAlumno))
)
)
)
?listaConvocatoriasAlumno contains multiples instances of a certain class and I would like to add some of these into another list (?listaConvocatoriasMismoCuadrimestre in this case) which at the beginning of the loop is empty.
Any idea?
Thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是忘记将插入返回值存储到列表变量中......我已经老了
Just forgot to store the insert return value into the list variable... I'm getting old