Have you ever wondered where you would
use the MAPCAR function?
Here is a perfect example :
Say you have a list of data stored in
(setq arglist '(12.0 145.8 67.2
You want to place each item in the list in
it's own variable to use in your routine. One way to do it would be as
(setq a (nth 0 arglist))
(setq b (nth 1 arglist))
(setq c (nth 2 arglist))
(setq d (nth 3 arglist))
This works, but is an extremely slow
way of processing the data as each variable requires a program statement.
A much more efficient way is to use the MAPCAR technique.
(mapcar 'set '(a b c d) arglist)
This routine maps the SET function to each
element of the first list and it's corresponding element of the second
list. SET is used instead of SETQ to evaluate each quoted element of the
first list. With the currently set arglist it sets a to 12.0, b
to 145.8, c to 67.2 and d to "M20".