[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(REDUCE #'OVERHEAD (MAP ...))
- To: MURRAY%cs.umass.edu@RELAY.CS.NET
- Subject: (REDUCE #'OVERHEAD (MAP ...))
- From: Brad Miller <miller@ACORN.CS.ROCHESTER.EDU>
- Date: Fri, 15 May 87 04:16 EDT
- Cc: common-lisp@SAIL.STANFORD.EDU, miller@ACORN.CS.ROCHESTER.EDU
- In-reply-to: <8704290611.AA12297@cayuga.cs.rochester.edu>
- Organization: University of Rochester, Department of Computer Science
- Phone: 716-275-7747
- Postal-address: 617 Hylan Building, University of Rochester, Rochester NY 14627
- Reply-to: email@example.com
- Sender: firstname.lastname@example.org
Date: Tue, 28 Apr 87 19:32 EDT
> From: James Larus <email@example.com>
> I use REDUCE quite frequently and recently ran across a strange
> interaction between it and another CL feature. I was trying to
> (reduce #'or (mapcar ...))
If you're doing a lot of stuff like this, maybe you should look into
the "Generic Mapping Functions" that Daniel Corkill has defined.
They do much of what REDUCE + MAP is used for, but
the notion of combining the results of mapping is generalized,
and is done more efficiently since it isn't always necessary to cons
up the intermediate results.
MAPCAR can be thought of as using CONS to combine mapping results.
The above use of OR is generally done through SOME in Common Lisp, but
is expressed using the Generalized Maps as MAPC-OR. EVERY is MAPC-AND, and
MAPCAN (MAPC-NCONC) functionality is done better as MAPC-CONDCONS.
MAPC-MAX is a popular one, as is MAPC-+ (MAPC-UNION, MAPC-AVERAGE, etc).
There are also MAPL-xxx functions that operate on sucessive sublists.
We have plans to extend these to work on sequences and not just lists,
but haven't done it yet (:- of course, they handle circular-lists :-)
The MAP-FUN general form takes a gob of keywords
to allow just about any mapping combination to be defined, and all the
others are defined in terms of it. They are Functions, but have
Compiler transforms that convert them into very efficient DO loops.
We can probably get the code to anyone interested.
- Kelly Murray
University of Massachusetts
Sorry if this is a repeat, but I am very interested in your conjoined mapping
functions... If you can mail it, terrific, if ftp access is better, let me
know, or if you want a tape...