mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 19:02:18 +00:00
18 lines
287 B
Nim
18 lines
287 B
Nim
# All and any
|
|
|
|
template all(container, cond: expr): expr =
|
|
block:
|
|
var result = true
|
|
for item in items(container):
|
|
if not cond(item):
|
|
result = false
|
|
break
|
|
result
|
|
|
|
if all("mystring", {'a'..'z'}.contains):
|
|
echo "works"
|
|
else:
|
|
echo "does not work"
|
|
|
|
|