Advertisement
Guest User

bajar-atomos

a guest
Jun 12th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (defun bajar-atomos (L)
  2. (labels ((depth (l)
  3. (cond ((null l) 0)
  4. ((atom (car l)) (depth (cdr l)))
  5. (t (max (1+ (depth (car l)))
  6. (1+ (depth (cdr l)))))))
  7. (rec (l target &optional (depth 1))
  8. (cond ((null l) nil)
  9. ((atom (car l)) (if (= target depth)
  10. nil
  11. (cons (car l)
  12. (rec (cdr l) target depth))))
  13. (t (cons (rec (car l) target (1+ depth))
  14. (rec (cdr l) target depth))))))
  15. (rec L (depth L))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement