cleanup old allany.nim example
This commit is contained in:
parent
5ad1acc60c
commit
cd1b0aa87e
1 changed files with 12 additions and 14 deletions
|
|
@ -1,22 +1,20 @@
|
|||
# All and any
|
||||
|
||||
template all(container, cond: untyped): bool =
|
||||
block:
|
||||
var result = true
|
||||
for it in items(container):
|
||||
if not cond(it):
|
||||
result = false
|
||||
break
|
||||
result
|
||||
var result = true
|
||||
for it in items(container):
|
||||
if not cond(it):
|
||||
result = false
|
||||
break
|
||||
result
|
||||
|
||||
template any(container, cond: untyped): bool =
|
||||
block:
|
||||
var result = false
|
||||
for it in items(container):
|
||||
if cond(it):
|
||||
result = true
|
||||
break
|
||||
result
|
||||
var result = false
|
||||
for it in items(container):
|
||||
if cond(it):
|
||||
result = true
|
||||
break
|
||||
result
|
||||
|
||||
if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`):
|
||||
echo "works"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue