Skip to content

Instantly share code, notes, and snippets.

@thisirs
Created November 28, 2012 16:48
Show Gist options
  • Save thisirs/4162463 to your computer and use it in GitHub Desktop.
Save thisirs/4162463 to your computer and use it in GitHub Desktop.
Function returning the place of an element in a tree
(defun place-of (item tree)
(let ((place (place-of-1 item tree "")))
(and place
(intern (concat "c" place "r")))))
(defun place-of-1 (item tree place)
(cond
((null tree))
((consp tree)
(let (found)
(while (and tree (not found))
(unless (setq found (place-of-1 item (car tree) (concat "a" place)))
(setq place (concat "d" place))
(setq tree (cdr tree))))
found))
(t (if (eq item tree) place))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment