Guest User

Untitled

a guest
Apr 12th, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import strutils
  2.  
  3. proc test[T](val: seq[T]) =
  4. echo "Sequence type $#..$#" % [$val.high, $val.low]
  5. proc test[T](val: T) =
  6. echo "Primitive type $# bytes" % [$val.sizeof]
  7. proc test[T](val:openarray[T]) =
  8. echo "Array type $#..$#" % [$val.high, $val.low]
  9.  
  10. var a: int = 4
  11. var b: seq[int] = @[0,1,2,3,4,5,6,7]
  12. var c: array[0..10, int]
  13.  
  14. when isMainModule:
  15. echo "A"
  16. test(a)
  17. echo "B"
  18. test(b)
  19. echo "C"
  20. test(c) # "Primitive type 88 bytes"
Advertisement
Add Comment
Please, Sign In to add comment