Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!orca!bullwinkle!ccampbel From: ccampbel@bullwinkle.dsd.es.com (Colin Campbell) Newsgroups: comp.lang.lisp Subject: Re: Accumlating maphash results Message-ID: <1991May16.004156.13152@dsd.es.com> Date: 16 May 91 00:41:56 GMT References: <1991May15.153918.23823@m.cs.uiuc.edu> Sender: usenet@dsd.es.com Reply-To: ccampbel@bullwinkle.dsd.es.com (Colin Campbell) Organization: Evans & Sutherland Computer Corp., Salt Lake City, UT Lines: 27 Nntp-Posting-Host: 130.187.91.214 In article <1991May15.153918.23823@m.cs.uiuc.edu>, carroll@cs.uiuc.edu (Alan M. Carroll) writes: > ... Currently, I do something like: > > (let ((results nil)) > (maphash #'(lambda (s o) (push (func o) results)) table) > results > ) > > However, this seems kludgy to me. Is there a cleaner way? Thanks! > Yes. If you want new functionality, IMPLEMENT it. (defun maphash-values (hash-table function) "Calls FUNCTION on each object in HASH-TABLE, returns a list of results" (let ((results nil)) (maphash #'(lambda (s o) (push (funcall s o) results)) table))) Now just use maphash-values (or whatever you call it). -- Colin Campbell Evans & Sutherland Salt Lake City, UT 84108 (801) 582-5847 ccampbel@dsd.es.com