Files
Nim/examples/allany.nim
2010-02-14 00:29:35 +01:00

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"