"Xcriber51 >" <Ken <ken-tusc@[EMAIL PROTECTED]
> wrote in message
news:5d7be11b299d14924c81dcc3ae4b0378@[EMAIL PROTECTED]
> OK, thanks everyone for dropping an explanation. Can't say I have fully
> appreciated the technical reasons, but I think I now know the human
> reasons involved.
>
> In summary, We have 3 solutions here:
>
I propose a fourth solution that might go something like:
PROCEDURE SoundexMap(ch: CHAR): INTEGER;
BEGIN
CASE CAP(ch) OF
"A", "E", "I", "O", "U":
RETURN 0 |
"B", "F", "P", "V":
RETURN 1 |
"C", "G", "J", "K", "Q", "S", "X", "Z":
RETURN 2 |
"D", "T":
RETURN 3 |
"H", "L":
RETURN 4 |
"M", "N":
RETURN 5 |
"R":
RETURN 6 |
"W", "Y":
RETURN 7
END
END SoundexMap;
It should be as efficient but much less obscure than the other three
solutions. Readers / maintainers of the code then have a better chance of
verifying that this algorithm is doing what it is intended to do. e.g. it
might lead to the question: Shouldn't "W", "Y" and "H" return 0 instead of
7, 7 and 4?
--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp


|