Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun exploded-lists (list)
- "Return an exploded list from LIST, returning all combinations where the sublists
- are replaced with singular atomic objects numbered :S1, :S2 and so forth."
- (let ((*keymap* nil))
- (declare (special *keymap*))
- (labels ((explosion (list)
- (cond ((null list) nil)
- (t (let* ((car (car list))
- (car-list (cond ((atom car) (list car))
- (t
- (push-to-exploded-list-keymap car)
- (cons (assoc-value car *keymap*) (explosion car)))))
- (cdr-list (explosion (cdr list))))
- (list-product car-list cdr-list))))))
- (values (explosion list) (reverse *keymap*)))))
Advertisement
Add Comment
Please, Sign In to add comment