Subject: Re: help me with this function
From: Erik Naggum <>
Date: 1996/03/24
Newsgroups: comp.lang.lisp
Message-ID: <>

[Kevin P Chugh]

|   i'm trying to write a function that takes two arguments - one is an
|   atom 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)
|   i've tried using with-collection and collect but i can't get them to work
|   properly- anyone have any ideas?

the body of a function with args car and list could be quite simple:

  (mapcan (lambda (cons) (if (eq (car cons) car) (cdr cons))) list)

it is more instructive for you to write a recursive function.  you may note
that (myfunc car list) is identical to (myfunc car (cdr list)) if (car list)
does not match car.  you get the idea.

in my next life, I want to be my cat