> I am often confused between the variants of the map functions: map,
> mapc, mapcar, mapcan, mapcon, maplist.
Yes, indeed. The names of these 6 functions are historic, they are in
most Lisp variants since early on.
> Is there a short one-line synposis/organization of these functions
> with the key words, and/or a mnemonic that you may use to remember the
There is a kind of systematic pattern. All 6 functions take an argument
funtion and one or several lists. But they differ in whether they
1. pass the whole (rest)list to the function, or only the CAR.
2. build a result list or not (i.e. whether they return something
useful or are just for the side-effects).
3. build the result list destructively (using the equivalent of 'con'
or 'conc') or non-destructively (using 'cons' or 'append').
Wole list Only CAR
No result | map | mapc
append | maplist | mapcar
concat | mapcon | mapcan
The logic of the naming might be (my interpretation):
* The "c" in 'mapc' means "CAR", as does the "car" in 'mapcar'
* 'maplist' passes the whole list, while 'mapcar' takes the CAR
* The "con" in 'mapcon' means "concat" while the "can" in
'mapcan' replaces the "o" with an "a" from "CAR".
Note that you can implement ALL these 6 functions using 'mapcon'. So
'mapcon' is the mother of all mapping functions (as also of 'find',
'filter' and so on). For example, instead of
: (mapcar inc (1 2 3))
-> (2 3 4)
you could as well write
: (mapcon '((L) (cons (inc (car L)))) (1 2 3))
-> (2 3 4)
or instead of
: (mapc println (1 2 3))
you could write
: (mapcon '((L) (println (car L)) NIL) (1 2 3))
and so on.
In general, all functions in the "Only CAR" column above can be replaced
by the "Whole list" functions if the argument function takes car of
applying 'car' to the argument list.
I hope this clears things up a little.