Add items iterator for slices
This commit is contained in:
parent
57fa8c6d3f
commit
8faac66abe
1 changed files with 6 additions and 0 deletions
|
|
@ -1738,6 +1738,12 @@ iterator items*(E: typedesc[enum]): E =
|
||||||
for v in low(E)..high(E):
|
for v in low(E)..high(E):
|
||||||
yield v
|
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.} =
|
iterator pairs*[T](a: openArray[T]): tuple[key: int, val: T] {.inline.} =
|
||||||
## iterates over each item of `a`. Yields ``(index, a[index])`` pairs.
|
## iterates over each item of `a`. Yields ``(index, a[index])`` pairs.
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue