Plaster

text
(defun combine-list-into-keyword (parents depth-of-combination &key (from-start nil) (ignore-positions '()) (all-parents nil)) "Combines the name of the parents with the parent names upto depth-of-combination, eg the node-name 'charles' with the node-parents being (sex height race name) and depth 2 would would become ':race-name-charles', but 4 would be ':sex-height-race-name-charles', depth is measured from right to left, so most recent parent first. If all-parents is set to t, then all the parents with the exception of the positions listed in ignore-positions will be used" (when (listp ignore-positions) (let ((items-to-remove (collect-positions-in-list parents ignore-positions))) (setf parents (remove-list-items-from-list items-to-remove parents)))) (let ((d-o-p (cond (all-parents (length parents)) ((< depth-of-combination 1) 1) ((< (length parents) depth-of-combination) (length parents)) (t depth-of-combination)))) (intern (format nil "~{~a~^-~}" (if from-start (subseq parents 0 d-o-p) (reverse (subseq (reverse parents) 0 d-o-p)))) "KEYWORD")))