2008-06-30 21:54:22 -04:00
|
|
|
(defun maplist (f l)
|
|
|
|
(if (null l) ()
|
|
|
|
(cons (f l) (maplist f (cdr l)))))
|
|
|
|
|
|
|
|
; produce a beautiful, toroidal cons structure
|
|
|
|
; make m copies of a CDR-circular list of length n, and connect corresponding
|
|
|
|
; conses in CAR-circular loops
|
|
|
|
; replace maplist 'identity' with 'copy-tree' for rapdily exploding memory use
|
|
|
|
(defun torus (m n)
|
|
|
|
(let* ((l (map-int identity n))
|
|
|
|
(g l)
|
|
|
|
(prev g))
|
|
|
|
(dotimes (i (- m 1))
|
|
|
|
(setq prev g)
|
|
|
|
(setq g (maplist identity g))
|
|
|
|
(rplacd (last prev) prev))
|
|
|
|
(rplacd (last g) g)
|
|
|
|
(let ((a l)
|
|
|
|
(b g))
|
|
|
|
(dotimes (i n)
|
|
|
|
(rplaca a b)
|
|
|
|
(setq a (cdr a))
|
|
|
|
(setq b (cdr b))))
|
|
|
|
l))
|
|
|
|
|
|
|
|
(defun cyl (m n)
|
|
|
|
(let* ((l (map-int identity n))
|
|
|
|
(g l))
|
|
|
|
(dotimes (i (- m 1))
|
|
|
|
(setq g (maplist identity g)))
|
|
|
|
(let ((a l)
|
|
|
|
(b g))
|
|
|
|
(dotimes (i n)
|
|
|
|
(rplaca a b)
|
|
|
|
(setq a (cdr a))
|
|
|
|
(setq b (cdr b))))
|
|
|
|
l))
|
|
|
|
|
|
|
|
(time (progn (print (torus 100 100)) nil))
|
2008-08-17 14:16:31 -04:00
|
|
|
;(time (dotimes (i 1) (load "100x100.lsp")))
|
2008-06-30 21:54:22 -04:00
|
|
|
; with ltable
|
|
|
|
; printing time: 0.415sec
|
|
|
|
; reading time: 0.165sec
|
|
|
|
|
|
|
|
; with ptrhash
|
|
|
|
; printing time: 0.081sec
|
|
|
|
; reading time: 0.0264sec
|