tvarious1.nim 770 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. discard """
  2. file: "tlenopenarray.nim"
  3. output: '''1
  4. 0
  5. Whopie
  6. 12
  7. 1.7'''
  8. """
  9. echo len([1_000_000]) #OUT 1
  10. type
  11. TArray = array[0..3, int]
  12. TVector = distinct array[0..3, int]
  13. proc `[]`(v: TVector; idx: int): int = TArray(v)[idx]
  14. var v: TVector
  15. echo v[2]
  16. # bug #569
  17. import deques
  18. type
  19. TWidget = object
  20. names: Deque[string]
  21. var w = TWidget(names: initDeque[string]())
  22. addLast(w.names, "Whopie")
  23. for n in w.names: echo(n)
  24. # bug #681
  25. type TSomeRange = object
  26. hour: range[0..23]
  27. var value: string
  28. var val12 = TSomeRange(hour: 12)
  29. value = $(if val12.hour > 12: val12.hour - 12 else: val12.hour)
  30. echo value
  31. # bug #1334
  32. var ys = @[4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2]
  33. #var x = int(ys.high / 2) #echo ys[x] # Works
  34. echo ys[int(ys.high / 2)] # Doesn't work