lisp123456

Untitled

Oct 19th, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. (defun exploded-lists (list)
  2. "Return an exploded list from LIST, returning all combinations where the sublists
  3. are replaced with singular atomic objects numbered :S1, :S2 and so forth."
  4. (let ((*keymap* nil))
  5. (declare (special *keymap*))
  6. (labels ((explosion (list)
  7. (cond ((null list) nil)
  8. (t (let* ((car (car list))
  9. (car-list (cond ((atom car) (list car))
  10. (t
  11. (push-to-exploded-list-keymap car)
  12. (cons (assoc-value car *keymap*) (explosion car)))))
  13. (cdr-list (explosion (cdr list))))
  14. (list-product car-list cdr-list))))))
  15. (values (explosion list) (reverse *keymap*)))))
Advertisement
Add Comment
Please, Sign In to add comment