Skip to content

Instantly share code, notes, and snippets.

@technicallyagd
Last active December 4, 2018 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technicallyagd/9626195fee66d3ea71aaee2f2234ee71 to your computer and use it in GitHub Desktop.
Save technicallyagd/9626195fee66d3ea71aaee2f2234ee71 to your computer and use it in GitHub Desktop.
Let's go crazy.
import macros
macro `&*`[J:static[int]](a: array[J, int], x: static[int]): untyped =
result = nnkBracket.newTree()
for i in 0 ..< x:
for j in 0 ..< J:
result.add a[j]
expandMacros:
let key = [1,2,3] &* 10
assert [1,3,1] &* 2 == [1,3,1,1,3,1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment