- ;|
- _$$$$$$$$ (3dp->2dp '(0 1 2))
- (0 1)
- |;
- (defun 3dp->2dp (plst)
- (if (null (cadr plst))
- nil
- (list (car plst) (cadr plst))
- )
- )
- ;|
- _$$$$$$$$ (3dpl->2dpl '((0 1 2)(3 4 5)(6 7 8)))
- ((0 1) (3 4) (6 7))
- |;
- (defun 3dpl->2dpl (plst) (mapcar '3dp->2dp plst))
- (defun 3dpl->2dpl2 (plst)
- (if (null plst)
- nil
- (cons (3dp->2dp (car plst)) (3dpl->2dpl2 (cdr plst)))
- )
- )
- ;| 简单比对一下 3dpl->2dpl 与 3dpl->2dpl2 运行时间 相差不大
- _$$$$$$$$ (calrpt 100000 '3DPL->2DPL2)
- (repeat 100000 (3DPL->2DPL2 'arglst))
- 运行时间: 0.639988 s.
- _$$$$$$$$ (calrpt 100000 '3DPL->2DPL)
- (repeat 100000 (3DPL->2DPL 'arglst))
- 运行时间: 0.670002 s.
- _$$$$$$$$ (calrpt 1000000 '3DPL->2DPL2)
- (repeat 1000000 (3DPL->2DPL2 'arglst))
- 运行时间: 6.364 s.
- _$$$$$$$$ (calrpt 1000000 '3DPL->2DPL)
- (repeat 1000000 (3DPL->2DPL 'arglst))
- 运行时间: 6.39602 s.
- |;
- ;|
- _$$$$$$$$ (-sub-cons-s '(0 1 2 3 4 5 6) 3)
- ((0 1 2) (3 4 5))
- |;
- (defun -sub-cons-s (lst n)
- (if (null lst)
- nil
- (if (< (length lst) n)
- nil
- (cons (ntha n lst) (-sub-cons-s (nthbc n lst) n))
- )
- )
- )
- ;|
- _$$$$$$$$ (consn 10)
- (0 1 2 3 4 5 6 7 8 9 10)
- |;
- (defun consn (i)
- (if (< i 0)
- nil
- (append (consn (- i 1)) (list i))
- )
- )
- (defun calrpt (n fun / tst tend)
- (setq arglist (-sub-cons-s (consn 1001) 3))
- (setq tst (getvar "DATE"))
- (repeat n (vl-catch-all-apply fun arglst))
- (setq tend (getvar "DATE"))
- (mapcar 'princ
- (list "(repeat "
- n
- " ("
- fun
- " '"
- "arglst"
- "))"
- "\n运行时间: "
- (* (- tend tst) 86400.0)
- " s.\n"
- )
- )
- (princ)
- )
|