Vertical Indent by rolf

(defun depth (s a b v) (cond ((eq a b) nil)
((eq (aref s a) #\() (cons v (depth s (+ a 1) b (+ v 1))))
((eq (aref s a) #\)) (cons (- v 1) (depth s (+ a 1) b (- v 1))))))\x09
(defun prt (s d m m2)
(let* ((z (make-string (length s) :initial-element #\space)))
(loop for i from 0 to (- (length z) 1) do
(if (eq (nth i d) m) 
(setf (aref z i) (aref s i))))
(princ (string-right-trim '(#\space) z)) (terpri)
(if (< m m2) (prt s d (+ m 1) m2))))
(loop
(let* ((s (read-line))
(d (depth s 0 (length s) 0))
(m (eval (cons 'max d))))
(prt s d 0 m)))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page