From ... From: Erik Naggum Subject: Re: help me with this function Date: 1996/03/24 Message-ID: <3036617570947380@arcana.naggum.no>#1/1 X-Deja-AN: 143960239 references: <4ivotl$akh@azure.acsu.buffalo.edu> organization: Naggum Software; +47 2295 0313 newsgroups: comp.lang.lisp [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