From: bbiker Date: 2007-06-08T03:00:12+09:00 Subject: Re: Mutually-Recursive Functions On Jun 7, 8:07 am, "Harry Kakueki" wrote: > On 6/7/07, Harry Kakueki wrote: > > > > > On 6/7/07, dbl...@wobblini.net wrote: > > > > Work-saving tip for the day: > > > > p [*"a".."ff"] > > > > :-) > > > > David > > > > -- > > > Q. What is THE Ruby book for Rails developers? > > > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > > > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > > > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > > > A. Ruby Power and Light, LLC (http://www.rubypal.com) > > > I was going to do this. > > > p ("a".."ff").each {|x| p x} > > > Harry > > Oops. > Don't need 2 p's. > > ("a".."ff").each {|x| p x} > > Harry > > -- > > A Look into Japanese Ruby List in Englishhttp://www.kakueki.com/- Hide quoted text - > > - Show quoted text - I am not exactly sure what the OP was trying to do .. except that it has to do with Columns in Excel. It does seems to me to be fairly complicated. If this off topic, please excuse. In Excel, columns may either have a numeric format or an alpha format. Columns range for 1 .. 255 (A .. IV). Since I do quite a bit of work using Excel from Ruby via WIN32OLE, I have written a couple of helper functions to convert a numeric column value to an alpha column value and vice versa. Note that alpha columns in Excel are all caps. Here they are, I hope that someone might find them useful. # method to convert from numeric column to alpha col # accepts numeric column 1 through 256 # returns alpha column A through IV # returns empty string on invalid input def n2a_col(num_col) # verify that it in the range of 1 to 255 return nil if num_col < 1 || num_col > 256 mostSD = num_col / 26 # SD = Significant Digit leastSD = num_col % 26 if leastSD == 0 mostSD -= 1 leastSD = 26 end leastSA = ('A'[0] + leastSD - 1 ).chr mostSA = mostSD > 0 ? ('A'[0] + mostSD - 1).chr : '' mostSA + leastSA end # method to convert from alpha column to numeric col # accepts alpha column A through IV # returns numeric column 1 through 255 # returns 0 on invalid input def a2n_col(alpha_col) # to uppercase alpha_col.upcase col_size = alpha_col.size case col_size when 1 return 0 if alpha_col < 'A' || alpha_col > 'Z' return alpha_col[0] - 'A'[0] + 1 when 2 return 0 if alpha_col < 'AA' || alpha_col > 'IV' return (alpha_col[0] - 'A'[0] + 1) * 26 + alpha_col[1] - 'A'[0] + 1 else return 0 end end