Artifact 8febfaaa399715621b75545602b48e0b2d511766:
- File tests/langbench/wc.py — 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: 478) [annotate] [blame] [check-ins using]
#!/usr/bin/python import os import sys def wordsplit(line): list = [] word = "" for c in line: if c.isspace(): if len(word) > 0: list.append(word) word = "" else: word += c if len(word) > 0: list.append(word) return list def main(): n = 0 for a in sys.argv[1:]: f = open(a) for line in f: words = wordsplit(line) n += len(words) f.close() print "%d\n" % n if __name__ == "__main__": main()