summary refs log tree commit diff stats
path: root/examples/allany.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-07-26 00:46:41 +0200
committerAraq <rumpf_a@web.de>2011-07-26 00:46:41 +0200
commit0e7f2ca3f1607ad51e7e69e1b367450a8299c526 (patch)
tree41d98c00a9cd763ec7731d0b9b94ce0757a99cca /examples/allany.nim
parent3ac9012361f6d6642455c0bc81cb9f49ae5e844a (diff)
downloadNim-0e7f2ca3f1607ad51e7e69e1b367450a8299c526.tar.gz
bugfixes; added events module, sequtils module
Diffstat (limited to 'examples/allany.nim')
-rwxr-xr-xexamples/allany.nim15
1 files changed, 12 insertions, 3 deletions
diff --git a/examples/allany.nim b/examples/allany.nim
index 4747ce0d6..8f84ba3fc 100755
--- a/examples/allany.nim
+++ b/examples/allany.nim
@@ -3,13 +3,22 @@
 template all(container, cond: expr): expr =
   block:
     var result = true
-    for item in items(container):
-      if not cond(item):
+    for it in items(container):
+      if not cond(it):
         result = false
         break
     result
 
-if all("mystring", {'a'..'z'}.contains): 
+template any(container, cond: expr): expr =
+  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"