[OS X Emacs] map-query-replace-regexp: why?

Enrico Franconi franconi at inf.unibz.it
Thu Sep 30 12:14:21 EDT 2010


On 30 Sep 2010, at 17:57, Jack Repenning wrote:

> While reading through the docs (OK, while waiting for my car-pool to arrive ;-), I stumbled upon the function map-query-replace-regexp, which is just like query-replace-regexp except that it takes a list of replacement values, and rotates among them. That's all straightforward and comprehensible and everything, except I can't for the life of me imagine *why* one would actually want to do this. And it doesn't seem to be used anywhere in the standard lisp libraries.
> 
> So, just curious: can anyone suggest a use for this curiously specific function?

This goes back to a typical lisp programming pattern, familiar to the older among us who did a lot of lisp programming in their youth :-)
Basically, lisp was used a lot to build functionalities on the fly, something like "a program which has an output another program which is then executed". A "mapping" of a function f onto a set of arguments A is a typical meta-construct in this paradigm: it concatenates (depending on the output type) the results of applying f to each ai∈A: something like map(f,A) = concat(f(a1), ..., f(an)). Sometimes, f has a side effect, or f has only a side effect (namely the output is empty); this is the case of map-query-replace-regexp (in emacs see also, e.g., map-y-or-n-p).
cheers
--e.

Enrico Franconi                  - franconi at inf.unibz.it
Free University of Bozen-Bolzano - http://www.inf.unibz.it/~franconi/
Faculty of Computer Science      - Phone: (+39) 0471-016-120
I-39100 Bozen-Bolzano BZ, Italy  - Fax:   (+39) 0471-016-009


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-emacs/attachments/20100930/3335d1e4/attachment.html>


More information about the MacOSX-Emacs mailing list