Skip to content

Instantly share code, notes, and snippets.

@kurohuku
Created July 24, 2010 08:11
Show Gist options
  • Save kurohuku/488524 to your computer and use it in GitHub Desktop.
Save kurohuku/488524 to your computer and use it in GitHub Desktop.
(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