diff options
author | dgp <dgp@users.sourceforge.net> | 2016-04-19 20:35:49 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-04-19 20:35:49 (GMT) |
commit | 66032e8a327e0498b0d8970307452f66c69be25c (patch) | |
tree | 345b92b9d0c1be0f8ff45032a38884929744545e /tests/langbench/wc.py | |
parent | 0a228666ae8b3189ae92ff7624263de1455c24ff (diff) | |
download | tcl-66032e8a327e0498b0d8970307452f66c69be25c.zip tcl-66032e8a327e0498b0d8970307452f66c69be25c.tar.gz tcl-66032e8a327e0498b0d8970307452f66c69be25c.tar.bz2 |
Fork of Tcl used in the "Little" project.
http://www.mcvoy.com/lm/little/index.html
Diffstat (limited to 'tests/langbench/wc.py')
-rw-r--r-- | tests/langbench/wc.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/langbench/wc.py b/tests/langbench/wc.py new file mode 100644 index 0000000..d2a8b50 --- /dev/null +++ b/tests/langbench/wc.py @@ -0,0 +1,30 @@ +#!/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() |