tcommand_as_expr.nim 554 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. discard """
  2. output: '''140
  3. 5-120-120
  4. 359
  5. 77
  6. -4
  7. -1
  8. -1'''
  9. """
  10. #import math
  11. import sequtils
  12. proc optarg(x:int, y:int = 0):int = x + 3 * y
  13. proc singlearg(x:int):int = 20*x
  14. echo optarg 1, singlearg 2
  15. proc foo(x: int): int = x-1
  16. proc foo(x, y: int): int = x-y
  17. let x = optarg foo 7.foo
  18. let y = singlearg foo(1, foo 8)
  19. let z = singlearg 1.foo foo 8
  20. echo x, y, z
  21. let a = [2,4,8].map do (d:int) -> int: d + 1
  22. echo a[0], a[1], a[2]
  23. echo(foo 8, foo 8)
  24. # bug #7582
  25. proc f(x: int): int = x
  26. echo f -4
  27. echo int -1 # doesn't compile
  28. echo int `-` 1 # compiles