| Paste number 80513: | Unknown list transform |
| Pasted by: | meingbg |
| When: | 1 year, 3 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1Q4H |
| Channel: | #lisp |
| Paste contents: |
(defun tassoc (path alist &key key (test nil) (test-not nil))
"A recursive assoc to operate on tree structures."
(let ((n (cond
((and (not test) (not test-not))
(assoc (first path) alist :key key))
((not test)
(assoc (first path) alist :key key :test-not test-not))
((not test-not)
(assoc (first path) alist :key key :test test))
(t (assoc (first path) alist :key key
:test test :test-not test-not)))))
(cond ((not (rest path)) n)
((not n) n)
(t (tassoc (rest path) n :key key :test test :test-not test-not)))))
Annotations for this paste:
| Annotation number 1: | Seems to work now, with test and test-not mutually exclusive |
| Pasted by: | meingbg |
| When: | 1 year, 3 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1Q4H/1 |
| Paste contents: |
(defun tassoc (path alist &key key (test nil) (test-not nil))
"A recursive assoc to operate on tree structures."
(let ((n (cond
((and (not test) (not test-not))
(assoc (first path) alist :key key))
((not test)
(assoc (first path) alist :key key :test-not test-not))
(t (assoc (first path) alist :key key :test test)))))
(cond ((not (rest path)) n)
((not n) n)
(t (tassoc (rest path) n :key key :test test :test-not test-not)))))