Spaces:
Running
Running
File size: 1,417 Bytes
f50d9d6 48d465b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# Check if any binary operator are overly complex
function flagBinOperatorComplexity(tree::Node, op::Int)::Bool
if tree.degree == 0
return false
elseif tree.degree == 1
return flagBinOperatorComplexity(tree.l, op)
else
if tree.op == op
overly_complex = (
((bin_constraints[op][1] > -1) &&
(countNodes(tree.l) > bin_constraints[op][1]))
||
((bin_constraints[op][2] > -1) &&
(countNodes(tree.r) > bin_constraints[op][2]))
)
if overly_complex
return true
end
end
return (flagBinOperatorComplexity(tree.l, op) || flagBinOperatorComplexity(tree.r, op))
end
end
# Check if any unary operators are overly complex
function flagUnaOperatorComplexity(tree::Node, op::Int)::Bool
if tree.degree == 0
return false
elseif tree.degree == 1
if tree.op == op
overly_complex = (
(una_constraints[op] > -1) &&
(countNodes(tree.l) > una_constraints[op])
)
if overly_complex
return true
end
end
return flagUnaOperatorComplexity(tree.l, op)
else
return (flagUnaOperatorComplexity(tree.l, op) || flagUnaOperatorComplexity(tree.r, op))
end
end
|