summary refs log tree commit diff stats
path: root/examples/talk/quasiquote.nim
Commit message (Expand)AuthorAgeFilesLines
* Change expr/stmt in examples to untyped (#6734)Lynn C. Rees2017-11-151-1/+1
* examples from the talk part of test suiteAraq2013-09-271-0/+11
10-01-05 00:34:15 +0100 further development of httpserver' href='/ahoang/Nim/commit/examples/allany.nim?h=devel&id=a8303679960a13aa9ddd1f2fa44c2e4f9a12f071'>a83036799 ^
0e7f2ca3f ^

a83036799 ^



72f2a6e27 ^
0e7f2ca3f ^








a83036799 ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

             
                                                         

                     

                               



                      
                                                         








                                                                     




                      
# All and any

template all(container, cond: expr): expr {.immediate.} =
  block:
    var result = true
    for it in items(container):
      if not cond(it):
        result = false
        break
    result

template any(container, cond: expr): expr {.immediate.} =
  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"