summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2015-04-03 11:09:56 +0200
committerdef <dennis@felsin9.de>2015-04-03 11:10:36 +0200
commit8faac66abe1fae381f68ff5eee586bfe250dbfe3 (patch)
tree20a51fa636c9aecd29efbcdd943d01641e78ce91 /lib
parent57fa8c6d3f535acc79ef8a67a6ef7aef0c7519da (diff)
downloadNim-8faac66abe1fae381f68ff5eee586bfe250dbfe3.tar.gz
Add items iterator for slices
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index ba0690ace..fa0c36a2d 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1738,6 +1738,12 @@ iterator items*(E: typedesc[enum]): E =
   for v in low(E)..high(E):
     yield v
 
+iterator items*[T](s: Slice[T]): T =
+  ## iterates over the slice `s`, yielding each value between `s.a` and `s.b`
+  ## (inclusively).
+  for x in s.a..s.b:
+    yield x
+
 iterator pairs*[T](a: openArray[T]): tuple[key: int, val: T] {.inline.} =
   ## iterates over each item of `a`. Yields ``(index, a[index])`` pairs.
   var i = 0
2 +0200 further adaptations' href='/ahoang/Nim/commit/tests/testament/specs.nim?h=devel&id=c6034277fcb597da03d064b773ad4f6823823fa0'>c6034277f ^
20b5f31c0 ^








3249f16d8 ^

20b5f31c0 ^











505836385 ^

20b5f31c0 ^


f12a0820e ^
20b5f31c0 ^
335c19c86 ^
20b5f31c0 ^


2fb5d6292 ^
20b5f31c0 ^
4ab56d6be ^
20b5f31c0 ^




16b15f360 ^
20b5f31c0 ^















6725aa363 ^
20b5f31c0 ^
16b15f360 ^
20b5f31c0 ^










6725aa363 ^
20b5f31c0 ^

335c19c86 ^
20b5f31c0 ^

505836385 ^

6725aa363 ^



20b5f31c0 ^









505836385 ^
6725aa363 ^
20b5f31c0 ^





f12a0820e ^

6725aa363 ^
20b5f31c0 ^
f49f2f38f ^




20b5f31c0 ^

335c19c86 ^

20b5f31c0 ^












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151