Skip to content

Instantly share code, notes, and snippets.

@flaviut
Created July 21, 2014 20:13
Show Gist options
  • Save flaviut/7cce3d8775861351abe4 to your computer and use it in GitHub Desktop.
Save flaviut/7cce3d8775861351abe4 to your computer and use it in GitHub Desktop.
proc cst*[T1, T2](item: T1, desc: typedesc[T2]): T2 =
T2(item)
proc arange*(n: int, T: typedesc): seq[T] =
result = newSeq[T](n)
for i, val in result:
result[i] = 0.cst(T)
discard arange(10, float)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment