(depth int)
| 219 | } |
| 220 | |
| 221 | func unaryNode(depth int) string { |
| 222 | op := random([]string{"-", "!", "not"}) |
| 223 | // Use a simple formatting to ensure valid unary expression syntax |
| 224 | if op == "not" { |
| 225 | return fmt.Sprintf("not %v", node(depth-1)) |
| 226 | } |
| 227 | return fmt.Sprintf("%s%v", op, node(depth-1)) |
| 228 | } |
| 229 | |
| 230 | func binaryNode(depth int) string { |
| 231 | return fmt.Sprintf("%v %v %v", node(depth-1), random(operators), node(depth-1)) |