tor.nim 461 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. output: '''0
  3. true
  4. 3'''
  5. """
  6. template arithOps: untyped = (`+` | `-` | `*`)
  7. template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a mod 10, b)
  8. let xx = 10
  9. echo 10*xx
  10. template t{x = (~x){y} and (~x){z}}(x, y, z: bool): typed =
  11. x = y
  12. if x: x = z
  13. var
  14. a = true
  15. b = true
  16. c = false
  17. a = b and a
  18. echo a
  19. # bug #798
  20. template t012{(0|1|2){x}}(x: untyped): untyped = x+1
  21. let z = 1
  22. # outputs 3 thanks to fixpoint iteration:
  23. echo z