tviews1.nim 323 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. output: '''11
  3. 22
  4. 33
  5. 3
  6. 2
  7. 3
  8. 3'''
  9. targets: "c cpp"
  10. """
  11. {.experimental: "views".}
  12. proc take(a: openArray[int]) =
  13. echo a.len
  14. proc main(s: seq[int]) =
  15. var x: openArray[int] = s
  16. for i in 0 .. high(x):
  17. echo x[i]
  18. take(x)
  19. take(x.toOpenArray(0, 1))
  20. let y = x
  21. take y
  22. take x
  23. main(@[11, 22, 33])