Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defnodelistfun ancestor working-nodes ()
- "Find the common ancestor of all elements."
- (loop with parentlists = (loop for node in working-nodes
- collect (reverse (nodefun-parents node)))
- for i = 0 then (1+ i)
- for prevparents = NIL then parents
- for parents = (loop for list in parentlists for el = (nth i list) if el collect el)
- until (or (not (every #'eql (list (first parents)) parents))
- (not (= (length parents) (length parentlists))))
- finally (return (list (first prevparents)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement