Created
July 24, 2010 08:11
-
-
Save kurohuku/488524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun make-nesting-print-fn (up-pre down-pre &optional (*standard-output* *standard-output*)) | |
(let ((counter 0)) | |
(list | |
;;count-up | |
(lambda (obj) | |
(incf counter) | |
(dotimes (i counter) | |
(format t "~A" up-pre)) | |
(format t "~A~%" obj) | |
obj) | |
;;count-down | |
(lambda (obj) | |
(dotimes (i counter) | |
(format t "~A" down-pre)) | |
(format t "~A~%" obj) | |
(unless (zerop counter) | |
(decf counter)) | |
obj)))) | |
(destructuring-bind (up down) | |
(make-nesting-print-fn ">" "<") | |
(setf (symbol-function 'nesting-print-up) up | |
(symbol-function 'nesting-print-down) down)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment