def leads
bend-lint-rules@0.2.0.0 · performance/deep_call_in_fork.bend:131
import bend-lint-rules@0.2.0.0/performance/deep_call_in_fork.bend as DeepCallInFork
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
131
132
133
134def leads(nodes: List<&2, Lint.Node>, many: Bool, one: Bool) -> Bool:
135 match nodes many one:
136 case _ True{} _:
137 True{}
138 case _ False{} False{}:
139 False{}
140 case Con{Lint.Node{Lint.Destructure{q}, n, s, +kids, f}, Nil{}} False{} True{}:
141 +count = binders(kids, 0n)
142 leads(kids, Nat.is_gt(count, 1n), Nat.is_eq(count, 1n))
143 case Con{x, Nil{}} False{} True{}:
144 False{}
145 case Con{x, rest} False{} True{}:
146 leads(rest, False{}, True{})
147 case Nil{} False{} True{}:
148 False{}