只需一步,快速开始
形如 <表>
如:
( (2 . 3) (4 . 8) (5 . a) (4 . 12))
这样的表. 针对于表对4, 可以用 (assoc 4 <表>) 来求得, 但这儿有两个的4的表对, 它只得出第一个. 下一个的4的表对,有什么方式也能求得出来?
是不是只能用到cdr或cddr 与 assoc 配合的循环读取 才能做到么?
使用道具 举报
;;; by Michael Puckett (defun cdrs (key lst / pair rtn) (while (setq pair (assoc key lst)) (setq lst (cdr (member pair lst)) rtn (cons (cdr pair) rtn) ) ) (reverse rtn))
Command: (setq lst '( (2 . 3) (4 . 8) (5 . a) (4 . 12)))((2 . 3) (4 . 8) (5 . A) (4 . 12))
Command: (cdrs 4 lst)(8 12)
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 ) ©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途
GMT+8, 2024-4-28 22:55 , Processed in 0.224587 second(s), 25 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.