Barry Margolin <barmar@alum.mit.edu> wrote:
+---------------
| Tim Bradshaw <tfb+google@tfeb.org> wrote:
| > > Second, why is it called mapcar? Every other Lisp I've looked at
| > > calls this function map.
| >
| > It's called MAPCAR because pretty much every other existing Lisp
| > called it MAPCAR too, and the CL designers wanted to cause minimal
| > upheaval to the millions of existing lines of code.
|
| Which begs the question: why did those earlier Lisps call it MAPCAR?
|
| I think earlier Lisps had a function called MAP. So when new mapping
| functions were added to the language, they were given different names:
| MAPC, MAPCAR, MAPCAN, MAPCON.
|
| By the time of Maclisp (the primary inspiration for CL) I think MAP had
| disappeared...
+---------------
According to <http://pdp-10.trailing-edge.com/mit_emacs_170_teco_1220/
01/info/maclisp-commands.info>, Maclisp still had MAP, but its args
and semantics were those of Common Lisp's MAPL, that is:
- Traversal like MAPLIST
- No accumulation of values; side-effecting only like MAPC
- Returns the first list arg as its value
> (mapl (lambda (x y z) (print (list x y z)))
'(1 2 3 4) '(a b c d e) '(+ - * /))
((1 2 3 4) (A B C D E) (+ - * /))
((2 3 4) (B C D E) (- * /))
((3 4) (C D E) (* /))
((4) (D E) (/))
(1 2 3 4)
>
+---------------
| ...but renaming one of the new functions would have caused
| compatibility problems. CL introduced a new MAP function,
| since the name was then available.
+---------------
The above URL says Maclisp had all of MAP, MAPC, MAPCAR, MAPLIST,
MAPCAN, & MAPCON -- all as we know them in CL, except that in CL
MAP got renamed to MAPL and MAP got recycled for the new function.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607