summary refs log blame commit diff stats
path: root/examples/allany.nim
blob: 4747ce0d64dd5d773ff89db27a783bcc4ab497a3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                           
# 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"