reverse-complement Matz's Ruby #5 program
source code
# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
#
# Contributed by Aaron Tavistock
LEADER = ">".freeze
CR = "\n".freeze
STDIN.each_line(LEADER).lazy.each do |chunk|
header, segment = chunk.split(CR, 2)
next unless segment
segment.delete!(CR+LEADER)
segment.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
STDOUT.write LEADER, header, CR
segment_size = segment.size
idx=0
while idx < segment_size do
STDOUT.write segment.byteslice(idx,60), CR
idx += 60
end
end
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
ruby 1.8.7
(2014-01-28
patchlevel 376)
[x86_64-linux]
Sat, 08 Jun 2024 00:55:36 GMT
COMMAND LINE:
/usr/share/rvm/rubies/ruby-1.8.7-head/bin/ruby revcomp.mri-5.mri 0 < revcomp-input250000.txt
PROGRAM FAILED
PROGRAM OUTPUT:
revcomp.mri-5.mri:9: undefined method `lazy' for #<Enumerable::Enumerator:0x7e445acb77b8> (NoMethodError)