Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbfsb!cbnewsc!cbnewsc!lgm From: lgm@cbnewsc.ATT.COM (lawrence.g.mayka) Newsgroups: comp.object Subject: Re: Heterogeneous lists (once more, with feeling!) Message-ID: Date: 17 Apr 91 14:10:21 GMT References: <1594@optima.cs.arizona.edu> <3810@ssc-bee.ssc-vax.UUCP> <1989:Apr1206:29:5291@kramden.acf.nyu.edu> <1991Apr14.211215.1818@visix.com> Sender: lgm@cbnewsc.att.com (lawrence.g.mayka) Organization: AT&T Bell Laboratories Lines: 30 In-Reply-To: adam@visix.com's message of 14 Apr 91 21:12:15 GMT In article <1991Apr14.211215.1818@visix.com> adam@visix.com writes: The MAPCAR example is from the more heterogeneous side, in that the only thing the objects necessarily have in common is "they all have the operation identified by parameter X, which takes as argument the object itself and returns another object" (not even that if you want MAPCAR to catch failures!) You could, of course, build a solution in C around that fact, creating a list of anonymous monadic functions for each application of MAPCAR. Actually, Common Lisp MAPCAR is more flexible than this. It takes one *or more* lists as arguments, and applies the given operation to corresponding elements of those lists. Moreover, the operation itself does not necessarily take a fixed number of arguments, either. Thus: (MAPCAR #'LIST '(A B)) => ((A) (B)) (MAPCAR #'LIST '(A B) '(C D)) => ((A C) (B D)) (MAPCAR #'LIST '(A B) '(C D) '(E F)) => ((A C E) (B D F)) MAPCAR is indeed a reusable abstraction. Lawrence G. Mayka AT&T Bell Laboratories lgm@iexist.att.com Standard disclaimer.