diff options
-rw-r--r-- | lib/system.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 8008cfe84..12c5c6303 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1696,6 +1696,13 @@ iterator items*(a: cstring): char {.inline.} = yield a[i] inc(i) +iterator mitems*(a: var cstring): var char {.inline.} = + ## iterates over each item of `a` so that you can modify the yielded value. + var i = 0 + while a[i] != '\0': + yield a[i] + inc(i) + iterator items*(E: typedesc[enum]): E = ## iterates over the values of the enum ``E``. for v in low(E)..high(E): @@ -1765,6 +1772,21 @@ iterator mpairs*(a: var string): tuple[key: int, val: var char] {.inline.} = yield (i, a[i]) inc(i) +iterator pairs*(a: cstring): tuple[key: int, val: char] {.inline.} = + ## iterates over each item of `a`. Yields ``(index, a[index])`` pairs. + var i = 0 + while a[i] != '\0': + yield (i, a[i]) + inc(i) + +iterator mpairs*(a: var cstring): tuple[key: int, val: var char] {.inline.} = + ## iterates over each item of `a`. Yields ``(index, a[index])`` pairs. + ## ``a[index]`` can be modified. + var i = 0 + while a[i] != '\0': + yield (i, a[i]) + inc(i) + proc isNil*[T](x: seq[T]): bool {.noSideEffect, magic: "IsNil".} proc isNil*[T](x: ref T): bool {.noSideEffect, magic: "IsNil".} |