Artifact f0dec4af5b532b11734b82f5e91976782321aea8:
- File tests/langbench/wc.rb — part of check-in [69b737f5a1] at 2016-04-19 20:35:49 on branch little — Fork of Tcl used in the "Little" project. http://www.mcvoy.com/lm/little/index.html (user: dgp, size: 354) [annotate] [blame] [check-ins using]
def wordsplit(line) list = [] word = "" line.split('').each do |c| if c =~ /\s/ if word.length > 0 list << word end word = "" else word += c end end if word.length > 0 list << word end return list end n = 0 while line = gets() words = wordsplit(line) n += words.length end printf("%d\n", n)