【发布时间】:2022-01-01 03:23:49
【问题描述】:
我想编写一个函数,它接受两个谓词函数列表和元素列表,并返回原始列表中包含 pre1_list 中所有谓词的所有成员,并删除原始列表中不包含 pre2_list 中所有谓词的成员
我正在用一种叫做 mini lisp 的语言编写这段代码,它与 lisp 类似,但更简单,但这没关系,我只是想知道如何做这样的事情?关于如何实现此类代码的想法!
我想怎么做:(只是我想法的开始)
(defun get_pred_1_not_2 (pre1_list pre2_list list)
(cond
((null list) NIL)
; return all the members in the original list that hold all the predicates in pre1_list
(pre1_list (get_pred_1_not_2 (cdr pre1_list) pre2_list (filter_pre list (car pre1_list))))
; delete all the members in the original list that unhold all the predicates in pre2_list
(pre2_list (get_pred_1_not_2 pre1_list (cdr pre2_list) ;.... (
其中filter_pre 是一个函数,它返回列表中包含对其的谓词的所有元素
我希望有人可以提供帮助!因为这个函数真的很难写,我不想放弃 谢谢
【问题讨论】:
标签: lisp common-lisp predicate partition mini-language