# Re: Mutually-Recursive Functions

**URL:** <https://www.ruby-forum.com/t/re-mutually-recursive-functions/106250>\
**Category:** Ruby\
**Created:** [June 7, 2007, 8:38pm UTC](https://www.ruby-forum.com/t/re-mutually-recursive-functions/106250 "2007-06-07T20:38:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [June 7, 2007, 8:38pm UTC](https://www.ruby-forum.com/t/re-mutually-recursive-functions/106250/1 "2007-06-07T20:38:17Z")

</div>

From: bbiker [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Thursday, June 07, 2007 12:00 PM

[snip]

> ```
> return alpha_col[0] - 'A'[0] + 1
> 
> ```

[snip]

I thought I’d point out that  
‘A’[0]  
is equivalent to  
?A  
…and I personally find the latter to be much more friendly.

For completeness, here’s how I’d write the name-to-number conversion as  
an auto-caching hash (without the bounds tests):

COL\_NUM = Hash.new{ |h,alpha|  
offset = ?A - 1  
alpha.upcase!  
case alpha.size  
when 1  
h[alpha] = alpha[0] - offset  
when 2  
h[alpha] = ( alpha[0] - offset ) \* 26 +  
( alpha[1] - offset )  
end  
}
