W
William James
James said:#!/usr/local/bin/ruby -w
module Kernel
def complete
loop { break unless yield }
end
end
if __FILE__ == $0
digits = "3211"
complete { digits.gsub!(/(\d)\1+/) { |d| d[0, 1].to_i + 1 } }
p digits # => "4"
end
complete { digits.gsub!(/(\d)\1+/) { $1.to_i + 1 } }