From 37229df7fc044fe108d2f4d88f127141cabeb6a6 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 22 Jan 2014 17:32:38 +0100 Subject: next steps for closure iterators --- tests/iter/tanoniter1.nim | 32 ++++++++++++++++++++++++++++++++ tests/iter/titer2.nim | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/iter/tanoniter1.nim (limited to 'tests/iter') diff --git a/tests/iter/tanoniter1.nim b/tests/iter/tanoniter1.nim new file mode 100644 index 000000000..9db5ab8ec --- /dev/null +++ b/tests/iter/tanoniter1.nim @@ -0,0 +1,32 @@ +discard """ + output: '''1 +2 +3 +4 +1 +2''' +""" + +proc factory(a, b: int): iterator (): int = + iterator foo(): int = + var x = a + while x <= b: + yield x + inc x + return foo + +proc factory2(a, b: int): iterator (): int = + return iterator (): int = + var x = a + while x <= b: + yield x + inc x + +let foo = factory 1, 4 + +for f in foo(): + echo f + +let foo2 = factory2 1,2 + +for f in foo2(): echo f diff --git a/tests/iter/titer2.nim b/tests/iter/titer2.nim index dab2713e8..f8967109e 100644 --- a/tests/iter/titer2.nim +++ b/tests/iter/titer2.nim @@ -1,6 +1,6 @@ discard """ output: '''true''' - cmd: "nimrod cc --gc:none --hints:on $# $#" + cmd: "nimrod cc --gc:none --hints:on --warnings:off $# $#" """ import hashes -- cgit 1.4.1-2-gfad0 m'>log blame commit diff stats
path: root/src/utils/widthconv.nim
blob: b649537994f2f2ca8ffc14bdabb690f7d5c4fe23 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14