@cdunn2001: For what (I guess) you are trying to achieve, I would go for something like: import tables proc complementsFrom(normal, complement: string): Table[char,char] = result = initTable[char,char]() for ix, ch in normal: result[ch] = complement[ix] proc reverseComplement(str: string): string = const complements = complementsFrom("ACGTacgtNn-", "TGCAtgcaNn-") result = newString(str.len) for ix, ch in str: result[str.high - ix] = complements[ch] echo reverseComplement("Gattaca")
**nim** has the nice feature that **const** are evaluated at compile time. So, const complements = complementsFrom("ACGTacgtNn-", "TGCAtgcaNn-") will only be evaluated at compile time.