本帖最后由 llsheng_73 于 2024-12-30 17:05 编辑
- (defun myNth(i l);;取表l的第i(>=0)项
- ((cadr(assoc i(list(list 0 car)(list 1 cadr)(list 2 caddr)(list 3 cadddr))))(if(> i 4)(while(> i 4)(setq i(- i 4)l(cddddr l)))l)))
- (defun myNth+N(i n l / funs lst);;第i(>=0)项及后续n个,返回的表长是(1+ n)
- (setq funs(list(list 0 car cdr)(list 1 cadr cddr)(list 2 caddr cdddr)(list 3 cadddr cddddr)))
- (while(> i 4)(setq i(- i 4)l(cddddr l)))
- (setq lst(list((cadr(assoc i funs))l))l((caddr(assoc i funs))l))
- (while(> n 4)(setq n(- n 4))(vl-every(function(lambda(x y)(setq lst(cons((cadr x)l)lst))))funs l)(setq l(cddddr l)))
- (while(and(<(length lst)n)l)(setq lst(cons(car l)lst)l(cdr l)))
- (reverse lst))
|