i'm trying to write a function that takes two arguments - one is
an ato the other is a list of lists - for each list within the
list, if the atom matches its first memeber, i want it's second
member to be added to a master list and finally returned- for
example:
(setq mylist '((a b)(a c)(a d)))
(myfunc 'a lst)
and myfunc would return
(b c d)
Kenny Tilton wrote:
I do not know of a one-step solution, but you could try:
(defun cullCar (match lists)
(delete-if #'null (mapcar #'(lambda (list)
(when (eql match (car list))
(cadr list)))
lists)))
This would be inefficent where many non-matches occur. Doesn't
the loop macro have some neat features for this? (Don't use it
myself.)
Scheme
(define (myfunc x lst)
(filter-map
(lambda(xs) (and (equal? x (car xs)) (cadr xs)))
lst))
(myfunc 'b '((b 2) (c 3) (b 4) (d 5) (b 6)))
===>
(2 4 6)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)