Created
November 28, 2012 16:48
-
-
Save thisirs/4162463 to your computer and use it in GitHub Desktop.
Function returning the place of an element in a tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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