mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
cleanup old allany.nim example
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user