On Wed, 12 Nov 2008 10:22:05 -0500, Justus Ohlhaver wrote:

> Ken Bloom wrote:
>> On Wed, 12 Nov 2008 08:16:36 -0500, Justus Ohlhaver wrote:
>> 
>>> Hello,
>>> 
>>> is there any method to quickly convert a text string such as 'Peter'
>>> into an integer? (And vice versa?)
>>> 
>>> I am not asking about just changing the format (to_i). I'm looking for
>>> a method thus can do the computation.
>>> 
>>> Thanks,
>>> Justus
>> 
>> Does "Peter".hash do what you want?
>> 
>> --Ken
> 
> Yes, thanks it seems to do what I need, except for two possible
> limitations:
> 
> 1.Accordinng to Sebastian (above) 'Hash values are not unique. Two
> different strings can have the same hash value'
> 
> 2.It may not serve my original purpose, which is speeding up database
> queries.

I'm going to suggest what Todd Benson and Rolando Abarca suggested, which 
is to just work with strings in the database. Don't bother with computing 
some kind of (possibly unique) hash. Use a CREATE INDEX statement to 
index the headline field, and you'll probably never notice a speed 
difference between your roundabout method and feeding in the string 
directly to the database.

--Ken

-- 
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/