From 405b86068e6a3d39970b9129ceec0a9108464b28 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 22 Jun 2008 16:14:11 +0200 Subject: Initial import --- tests/titer.nim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tests/titer.nim (limited to 'tests/titer.nim') diff --git a/tests/titer.nim b/tests/titer.nim new file mode 100755 index 000000000..736ba3155 --- /dev/null +++ b/tests/titer.nim @@ -0,0 +1,39 @@ +# Test the new iterators + +import + io + +iterator xrange(fromm, to: int, step = 1): (a: int) = + a = fromm + while a <= to: + yield a + inc(a, step) + +iterator interval[T](a, b: T): (x: T) + +iterator interval[T](a, b: T): (x: T) = + x = a + while x <= b: + yield x + inc(x) + +# +#iterator lines(filename: string): (line: string) = +# var +# f: tTextfile +# shouldClose = open(f, filename) +# if shouldClose: +# setSpace(line, 256) +# while readTextLine(f, line): +# yield line +# finally: +# if shouldClose: close(f) +# + +for i in xrange(0, 5): + for k in xrange(1, 7): + write(stdout, "test") + +for j in interval(45, 45): + write(stdout, "test2!") + write(stdout, "test3?") -- cgit 1.4.1-2-gfad0