Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Printing Text with the format Functi... > Iterating Through Lists Using Contro...

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 each of its items to the specified section of the control string.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint