Iterating Through Lists Using Control Sequences

The format function with its many control sequences is practically a programming language in its own right. (In fact, many Lispers would call it a domain-specific language, a concept we will revisit in Chapter 17.) And, like most programming languages, format can loop through data. It does this using the ˜{ and ˜} control sequences.

To achieve this looping, pass the format function a control string containing ˜{ and ˜}, and a list to iterate through. The part of the control string between the ˜{ and ˜} sequences is treated almost like the body of a loop. It will be executed a number of times, depending on the length of the list that follows it. The format function will iterate through this list, applying ...

Get Land of Lisp now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.