Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun deepth (list)
- (if (atom list)
- 0
- (1+ (reduce (function max) list :key (function deepth) :initial-value 0))))
- (defun flatten-before-deepest (list)
- (case (deepth list)
- (0 list)
- (1 list)
- (2 (flatten list))
- (otherwise (mapcar (function flatten-before-deepest) list))))
- (flatten-before-deepest '(a (b (c) d) e ((f g) h i) j))
- ;; --> (a (b c d) e (f g h i) j)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement