tlowhigh.nim 348 B

12345678910111213141516171819202122232425
  1. discard """
  2. file: "tlowhigh.nim"
  3. output: "10"
  4. """
  5. # Test the magic low() and high() procs
  6. type
  7. myEnum = enum e1, e2, e3, e4, e5
  8. var
  9. a: array [myEnum, int]
  10. for i in low(a) .. high(a):
  11. a[i] = 0
  12. proc sum(a: openarray[int]): int =
  13. result = 0
  14. for i in low(a)..high(a):
  15. inc(result, a[i])
  16. write(stdout, sum([1, 2, 3, 4]))
  17. #OUT 10