Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4.
- > (setq pars '|{|)
- {
- > (setq pard '|}|)
- }
- > (setq mylist '(a b (c d) (e f g) h))
- (A B (C D) (E F G) H)
- > (defun space (niv)
- (do ((n niv (- n 1)))
- ((= 0 n) (princ '| |))
- (princ '| |)
- )
- )
- SPACE
- > (defun print (l n)
- (princ (space n))
- (princ pars)
- (do ((lst l (cdr lst)))
- ((null (cdr lst)) (princ (car lst))(princ pard)(terpri)(princ '| |))
- (princ (car lst))(terpri)(princ '| |)(princ '| |)(princ (space n))
- )
- )
- PRINT
- > (defun print2 (l)
- (princ pars)
- (do ((lst l (cdr lst)) (n -2))
- ((null (cdr lst))(princ (car lst))(princ pard)(terpri))
- (cond ((atom (car lst))(princ (car lst))(terpri)(princ '| |))
- (t (setq n (+ 2 n))(print (car lst) n)))
- )
- )
- PRINT2
- > (print2 mylist)
- {A
- B
- {C
- D}
- {E
- F
- G}
- H}
- NIL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement