123456789101112131415161718192021222324252627 |
- # 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
- template any(container, cond: untyped): bool =
- block:
- 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"
- else:
- echo "does not work"
|