Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Last active August 29, 2015 13:57
Show Gist options
  • Save BitPuffin/1bc3cb5f97c5372c551c to your computer and use it in GitHub Desktop.
Save BitPuffin/1bc3cb5f97c5372c551c to your computer and use it in GitHub Desktop.
proc `$`*(a: TVector): string {.noSideEffect.} =
result = ""
result &= "["
var h = high(a)
for i in low(a)..h:
result &= $a[i]
if i != h:
result &= ", "
result &= "]"
@zah
Copy link

zah commented Mar 10, 2014

This works for me:

type 
  V[T; I: static[int]] = array[0..I, T]

proc `$$`(x: V): string =
  result = ""
  result &= "["
  var h = high(x)
  for i in low(x)..h:
    result &= $x[i]
    if i != h:
      result &= ", "
  result &= "]"


const xx: V[int, 3] = [1, 2, 3, 4]
static: echo($$xx)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment