The describe-paths function (from a text adventure game in Lisp Earth !) Generates descriptions for paths from a specific location. Pages 74-77 in Lisp Earth explain the roles of mapcar and append in this example.
(cdr (assoc location edges)) contains a list of all the paths going from the location, for example, for the living-room location:
((GARDEN WEST DOOR) (ATTIC UPSTAIRS LADDER))
mapcar calls the describe-path function for each of the paths, collecting the path descriptions in a list in which each of the subscriptions is a path description:
((THERE IS A DOOR GOING WEST FROM HERE.) (THERE IS A LADDER GOING UPSTAIRS FROM HERE.))
Next, the append function is applied to the list of path descriptions, combining it into a flat list:
(THERE IS A DOOR GOING WEST FROM HERE. THERE IS A LADDER GOING UPSTAIRS FROM HERE.)
Terje norderhaug
source share