Clips 剪辑中的过滤功能

Clips 剪辑中的过滤功能,clips,Clips,我试图定义这个函数,它接受多个整数,并保留与0不同的整数。显然,它不起作用,递归调用(filter$?tail)与参数列表不匹配。这可以在剪辑中完成吗 (deffunction filter (?head $?tail) (if (= (length $?tail) 0) then (if (!= ?head 0) then (return ?head)) (return $?tail)) (if (= ?head 0) then

我试图定义这个函数,它接受多个整数,并保留与0不同的整数。显然,它不起作用,递归调用
(filter$?tail)
与参数列表不匹配。这可以在剪辑中完成吗

(deffunction filter (?head $?tail)
    (if (= (length $?tail) 0) then
        (if (!= ?head 0) then (return ?head))
        (return $?tail))
    (if (= ?head 0) then
        (return (filter $?tail)))
    (bind $?result ?head (filter $?tail)) 
    (return $?result)
)

函数filter是用两个参数
filter(?head$?tail)
声明的,但是您只用一个
(filter$?tail)

是否需要递归?使用函数
delete member$
可以轻松解决此问题:

(delete-member$ $?list 0)
例如:

CLIPS> (delete-member$ (create$ 6 7 0 8 0 7) 0)
(6 7 8 7)
CLIPS> 

我真的不需要这个特殊的函数,但我需要一个工作方式大致相同的函数。我只是发布了这个更简单的版本来减少混乱。@PaulManta然后将调用
(filter$$?tail)
替换为
(filter(first$$?tail)$?tail)
来解决它?它不应该是类似的东西吗
(filter(first$$?tail)(tail$$?tail))
,否则递归永远不会结束吗?