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

Justifying Output

The format command also gives us a lot of control over text justification. Control sequences allow us to format tables, center text, and perform other useful justification feats.

To help you understand the various justification rules, we’ll create a simple function that returns different animal names with varying character lengths:

> (defun random-animal ()
      (nth (random 5) '("dog" "tick" "tiger" "walrus" "kangaroo")))
RANDOM-ANIMAL
> (random-animal)
"walrus"

Now suppose we want to display a bunch of random animals in a table. We can do this by using the ˜t control sequence. ˜t can take a parameter that specifies the column position at which the formatted value should appear. For example, to have our table of animals appear in three columns at the fifth, fifteenth, and twenty-fifth character positions, we could create this table:


  

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