Last active
December 4, 2018 16:29
-
-
Save technicallyagd/9626195fee66d3ea71aaee2f2234ee71 to your computer and use it in GitHub Desktop.
Let's go crazy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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