| 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | type AST struct { |
| 6 | Num int |
| 7 | Children []AST |
| 8 | } |
| 9 | |
| 10 | func newAST(num int, root AST, children ...AST) AST { |
| 11 | return AST{num, append([]AST{root}, children...)} |
| 12 | } |
| 13 | |
| 14 | func main() { |
| 15 | ast := newAST(1, AST{}, AST{}) |
| 16 | fmt.Println(ast) |
| 17 | } |
| 18 | |
| 19 | // Output: |
| 20 | // {1 [{0 []} {0 []}]} |