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)
Previous text:
2003-09-28 08:09: Subject: zero_type();
I've been doing some calculations on genome mutations and I've been finding myself doing a lot of
if(zero_type(foo) && zero_type(bar) ... && zero_type(gonk)) ...
when checking up on user input that is used to index mappings.
Could you explain some more why you land at testing a lot of zero_types? I didn't quite get the reason...
/ Mirar