...needs to be optimized, but it can stand comparison.
(defun ALE_List_Slice (i n l)
(ALE_List_CdrByLen (1+ (- n i)) (ALE_List_RevCdrByLen (1+ n) l))
)
(defun ALE_List_CdrByLen (n l / r g)
(setq g (- (length l) n))
(cond
( (> g 1000)
(repeat (/ g 1000) (setq l (Cd1000r l)))
(repeat (/ (setq g (rem g 1000)) 100) (setq l (Cd100r l)))
(repeat (/ (setq g (rem g 100)) 10) (setq l (Cd10r l)))
(repeat (/ (setq g (rem g 10)) 4) (setq l (cddddr l)))
(repeat (rem g 4) (setq l (cdr l)))
l
)
( T
(setq l (reverse l))
(repeat (/ n 10)
(setq
r
(vl-list*
(cadddr (cddddr (cddr l))) (cadddr (cddddr (cdr l)))
(cadddr (cddddr l)) (cadddr (cdddr l)) (cadddr (cddr l))
(cadddr (cdr l)) (cadddr l) (caddr l) (cadr l) (car l) r
)
l (cddddr (cddddr (cddr l)))
)
)
(repeat (rem n 10) (setq r (cons (car l) r) l (cdr l) ))
r
)
)
)
Benchmark.lsp | © 2005 Michael Puckett | All Rights Reserved
List > '(0 1 2 3 4 5 6 7 8 9)
Elapsed milliseconds / relative speed for 32768 iteration(s):
(_SLICE 2 6 (QUOTE (0 1 2 3 4 5 6 7 ...).....1248 / 1.06 <fastest>
(ALE_LIST_SLICE 2 6 (QUOTE (0 1 2 3 ...).....1326 / 1 <slowest>
> (setq Alist (atoms-family 1))
> (length aList) > 4005
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 101 4000 ALIST).............1061 / 3.22 <fastest>
(ALE_LIST_SLICE 101 4000 ALIST).....3417 / 1 <slowest>
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 101 3000 ALIST).............1076 / 2.67 <fastest>
(ALE_LIST_SLICE 101 3000 ALIST).....2870 / 1 <slowest>
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 101 2000 ALIST).............1123 / 1.89 <fastest>
(ALE_LIST_SLICE 101 2000 ALIST).....2121 / 1 <slowest>
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 101 1000 ALIST).............1045 / 1.28 <fastest>
(ALE_LIST_SLICE 101 1000 ALIST).....1342 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(ALE_LIST_SLICE 101 800 ALIST).....1919 / 1.07 <fastest>
(_SLICE 101 800 ALIST).............2059 / 1 <slowest>
Elapsed milliseconds / relative speed for 4096 iteration(s):
(ALE_LIST_SLICE 101 400 ALIST).....1857 / 2.31 <fastest>
(_SLICE 101 400 ALIST).............4290 / 1 <slowest>
Elapsed milliseconds / relative speed for 8192 iteration(s):
(ALE_LIST_SLICE 101 200 ALIST).....1763 / 4.68 <fastest>
(_SLICE 101 200 ALIST).............8252 / 1 <slowest>
Elapsed milliseconds / relative speed for 8192 iteration(s):
(ALE_LIST_SLICE 10 101 ALIST).....1155 / 7.24 <fastest>
(_SLICE 10 101 ALIST).............8362 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(_SLICE 1010 3000 ALIST).............1935 / 1.14 <fastest>
(ALE_LIST_SLICE 1010 3000 ALIST).....2199 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(ALE_LIST_SLICE 1010 2000 ALIST).....1856 / 1.06 <fastest>
(_SLICE 1010 2000 ALIST).............1966 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(_SLICE 1000 1010 ALIST).............1825 / 1.03 <fastest>
(ALE_LIST_SLICE 1000 1010 ALIST).....1872 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(_SLICE 800 1010 ALIST).............1981 / 1.09 <fastest>
(ALE_LIST_SLICE 800 1010 ALIST).....2153 / 1 <slowest>
Elapsed milliseconds / relative speed for 2048 iteration(s):
(_SLICE 400 1010 ALIST).............1997 / 1.16 <fastest>
(ALE_LIST_SLICE 400 1010 ALIST).....2309 / 1 <slowest>
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 200 1010 ALIST).............1014 / 1.29 <fastest>
(ALE_LIST_SLICE 200 1010 ALIST).....1311 / 1 <slowest>
Elapsed milliseconds / relative speed for 1024 iteration(s):
(_SLICE 10 1010 ALIST).............1123 / 1.36 <fastest>
(ALE_LIST_SLICE 10 1010 ALIST).....1529 / 1 <slowest>