From: Julian Leviston Date: 2013-03-31T01:29:29+09:00 Subject: Re: Translation Project On 31/03/2013, at 1:42 AM, sto.mar@web.de wrote: > Am 30.03.2013 08:19, schrieb Julian Leviston: >> >> >> On 30/03/2013, at 3:42 AM, Jeremy Henderson wrote: >> >>> Yes, I love how compressed it is. Like Regis' though, it can't handle >>> apostrophes. I assume I'll need to add some kind of exception for them >>> into it. >> >> By the way, compressed is overrated IMHO. If you love compressed, you might like PERL, or if you like powerful ideas expressed simply, you might like LISP. >> However, when it comes time to actually maintain code (and all code needs maintaining), you will probably find simple Ruby to be much easier to read and understand. >> >> Clarity around capturing of intent can't be overrated in my opinion when it comes time to programming. > > I don't have the previous messages around anymore, so I'm not sure > whether this has been brought up before, but I don't think so. > > Very clear in my opinion is String#tr: > > "hello world".tr('aeiou', '*') # => "h*ll* w*rld" > > > -- > > I apologise! You're absolutely right! This will translate single characters in place. I didn't understand what it did. Silly me. class String def dna_conv self.upcase.tr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "AAAAAABBBBBBCCCCCCDDDDDDDD") end end puts "DNAS: Sequencing Open... Input? " while (word=$stdin.gets.chomp).size>1 puts word.dna_conv puts puts "DNAS: Additional Input? " end Julian