If it's done a lot, do you need the error checking at that point?
It seems like a lot of work that in the normal case isn't necessary...
Does zero_type really work in that context? If you store it in an int variable, is it guaranteed to work?
Also, you could do
if (zero_type(index1 = amino_acid[str1]) || ... zero_type(indexn = amino_acid[strn]))
if you want to, which is probably safer zero-typewise. :)
(Just suggesting options.)
/ Mirar
Previous text:
2003-09-28 14:11: Subject: zero_type();
I get a lot of input with the letters "A"-"V" and "-". I use this input as an index (with a value that is stored in a mapping) to retrive data in some arrays.
I could do something like
if( amino_acid[str1] && amino_acid[str2] ... &amino_acid[strn] )
but this would that I do twice as many lookups in the amion_acid-mapping than I really need too (this is done _a lot_). Oh, and 0 is one of the values returned from the amino_acid-mapping. Of course I _could_ bump the numbers one step and subtract -1 for all indices...
Therefore I do it like this
index1 = amino_acid[str1]; ... indexn = amino_acid[strn]; if( zero_type(index1) && ... && zero_type(indexn) )
//use the indices quite a bit more
/ Peter Lundqvist (disjunkt)