rebuildAndChain assembles a left-folded AndNode chain from a non-empty slice.
(terms []ConditionNode)
| 173 | |
| 174 | // rebuildAndChain assembles a left-folded AndNode chain from a non-empty slice. |
| 175 | func rebuildAndChain(terms []ConditionNode) ConditionNode { |
| 176 | if len(terms) == 1 { |
| 177 | return terms[0] |
| 178 | } |
| 179 | result := ConditionNode(&AndNode{Left: terms[0], Right: terms[1]}) |
| 180 | for _, t := range terms[2:] { |
| 181 | result = &AndNode{Left: result, Right: t} |
| 182 | } |
| 183 | return result |
| 184 | } |
| 185 | |
| 186 | // termSubsumedBy returns true when cand is subsumed by sub, meaning sub |= cand |
| 187 | // (cand is "more specific"). In a disjunction this makes cand redundant: |