From: pixelnate Date: 2006-07-28T04:55:59+09:00 Subject: Re: Learn to Program - Solutions? William James wrote: > > toc = ['Table of Contents', 'Chapter 1', 'Getting Started', > 'page 1', 'Chapter 2', 'Numbers', 'page 9', > 'Chapter 3', 'Letter', 'page 13'] > > wd = 60 > > puts toc.shift.center(wd) > > toc.inject([]){ |a,e| > a << e > if 3 == a.size > a[0,2] = a[0,2].join( ": " ) + " " > a.push " " + a.pop[ /\d+/ ] > print a.first, "." * (wd - a.first.size - a.last.size), > a.last, "\n" > a.clear > end > a > } > > Thank you. I think you have some things in there that hadn't yet been mentioned in the book, but it gives me something to study. pixelNate