"Hal E. Fulton" <hal9000 / hypermetrics.com> wrote:

> Code below. Improvement/critique welcome.

[snip code]

Simplified scan, moved error check outside loop, added eval binding
context, and wrote a haiku.

class String
  def values (bind=nil)
    res = []
    str = ''
    scan(/\S+\s*/).each { |tok|
      begin
        res << eval(str << tok, bind)
        str = ''
      rescue Exception
      end
    }
    str.empty? or raise "Bad value near: #{str}"
    res
  end
end

a = "I n c r e m e n t a l"

a = <<EOF.values binding
  111 proc do |x| x.to_i.chr end <<-1
   82
  117    Refactoring code
   98    Insert seven syllables
  121    One line at a time
    1
   33 callcc {|x| x} print(a[0].chr,a[-2,2])
EOF

a.size < a[0] and a[4].call or puts "ve #{a[2].map(&a[1])}" << a[3]

--
Tabby