Added indexOf template.
This commit is contained in:
parent
2a052ac96b
commit
8122660da3
@ -26,7 +26,18 @@ proc sameContents*[T](a1, a2: openArray[T]): bool =
|
||||
if not a2.anyIt(a == it): return false
|
||||
return true
|
||||
|
||||
template doWhile(a, b: untyped): untyped =
|
||||
template indexOf*(s, pred: untyped): int =
|
||||
var foundIdx = -1
|
||||
var idx = 0
|
||||
for it {.inject.} in items(s):
|
||||
if pred:
|
||||
foundIdx = idx
|
||||
break
|
||||
idx += 1
|
||||
foundIdx
|
||||
|
||||
template doWhile*(a, b: untyped): untyped =
|
||||
b
|
||||
while a:
|
||||
b
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Language extensions (templates, macros) I commonly use."
|
||||
license = "MIT"
|
||||
|
Loading…
x
Reference in New Issue
Block a user