Created
November 11, 2013 15:23
-
-
Save acolley/7414855 to your computer and use it in GitHub Desktop.
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 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