tarray.nim 753 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. discard """
  2. file: "tarray.nim"
  3. output: "100124"
  4. """
  5. # simple check for one dimensional arrays
  6. type
  7. TMyArray = array[0..2, int]
  8. TMyRecord = tuple[x, y: int]
  9. proc sum(a: TMyarray): int =
  10. result = 0
  11. var i = 0
  12. while i < len(a):
  13. inc(result, a[i])
  14. inc(i)
  15. proc sum(a: openarray[int]): int =
  16. result = 0
  17. var i = 0
  18. while i < len(a):
  19. inc(result, a[i])
  20. inc(i)
  21. proc getPos(r: TMyRecord): int =
  22. result = r.x + r.y
  23. write(stdout, sum([1, 2, 3, 4]))
  24. write(stdout, sum([]))
  25. write(stdout, getPos( (x: 5, y: 7) ))
  26. #OUT 10012
  27. # bug #1669
  28. let filesToCreate = ["tempdir/fl1.a", "tempdir/fl2.b",
  29. "tempdir/tempdir2/fl3.e", "tempdir/tempdir2/tempdir3/fl4.f"]
  30. var found: array[0..filesToCreate.high, bool]
  31. echo found.len