Skip to content

Instantly share code, notes, and snippets.

@acolley
Created November 11, 2013 15:23
Show Gist options
  • Save acolley/7414855 to your computer and use it in GitHub Desktop.
Save acolley/7414855 to your computer and use it in GitHub Desktop.
import strutils
type
TThing = ref object
data: int
children: seq[TThing]
proc `$`(t: TThing): string =
result = "($1, $2)" % @[$t.data, join(map(t.children, proc(th: TThing): string = $th), ", ")]
proc somethingelse(): seq[TThing] =
result = @[TThing(data: 20, children: @[])]
proc dosomething(): seq[TThing] =
var atom = somethingelse()
atom = @[TThing(data: 10, children: atom)]
result = atom
when isMainModule:
echo($dosomething()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment