Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2016-05-22T13:04:44Z

Updated

2016-05-22T13:04:44Z

import Macros

macro scope*(body: untyped): untyped =
  if kind(body) != nnkDo: return body
  else:
    result = newNimNode(nnkStmtListExpr)
    for child in body[6]: add(result, child)

let a = scope do:
  var s = newSeq[int]()
  for i in .. <10:
    add s, i
  s

echo a
INFO