From: Julian Leviston Date: 2013-03-31T00:11:08+09:00 Subject: Re: Translation Project While not as brief, the code that follows *is* more understandable IMHO: class String def dna_conv self.upcase.each_char.map do |input_char| case when "ABCDEF"[input_char] then "A" when "GHIJKL"[input_char] then "B" when "MNOPQR"[input_char] then "C" when "STUVWXYZ"[input_char] then "D" else " " end end.join end end puts "DNAS: Sequencing Open... Input? " while (word=$stdin.gets.chomp).size>1 puts word.dna_conv puts puts "DNAS: Additional Input? " end On 31/03/2013, at 1:59 AM, Julian Leviston wrote: > > > 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" >> >> >> -- >> >> > > It is very clear, but it doesn't help here, does it? What we want is parallel translation. > > Julian > > >