Skip to content

Instantly share code, notes, and snippets.

@Vindaar
Last active December 4, 2018 16:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vindaar/6d0e550e9b8944b30f6b030deda271fc to your computer and use it in GitHub Desktop.
Save Vindaar/6d0e550e9b8944b30f6b030deda271fc to your computer and use it in GitHub Desktop.
import macros, typetraits
macro `&*`[T; N: static[int]](a: array[N, T], x: static[int]): untyped =
result = nnkBracket.newTree()
for i in 0 ..< x:
for j in 0 ..< N:
result.add a[j]
let key = [0] &* 10
echo name(type(key))
let key2 = [1, 2] &* 5
echo key2
let key3 = [1.5] &* 10
echo key3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment