LoopInvariantCall.invariant: def of bend-lint-rules@0.2.0.0 Import: import bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend as LoopInvariantCall Lines 141-162 of bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend: https://jend.leeeet.dev/read.txt?path=bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend&start_line=141&end_line=162 import Base import bend-lint-api@0.2.0.0/linter/lint.bend as Lint # Whether `nodes`, the arguments of a call, are the same on every step: literals, the variables of `fixed`, and calls, # annotations or constructions of those alone; `fuel` bounds the depth. def invariant(+fuel: Nat, nodes: List<&2, Lint.Node>, +fixed: List<&2, U32>, ok: Bool) -> Bool: match fuel nodes ok: case _ _ False{}: False{} case _ Nil{} True{}: True{} case 0n _ True{}: False{} case 1n+f Con{Lint.Node{Lint.Literal{t}, n, s, k, fs}, rest} True{}: invariant(f, rest, fixed, True{}) case 1n+f Con{Lint.Node{Lint.Variable{v}, n, s, k, fs}, rest} True{}: invariant(f, rest, fixed, List.contains(~U32, ~U32.is_eq, fixed, v)) case 1n+f Con{Lint.Node{Lint.Application{}, n, s, Con{h, args}, fs}, rest} True{}: invariant(f, rest, fixed, invariant(f, args, fixed, True{})) case 1n+f Con{Lint.Node{Lint.Annotation{}, n, s, Con{x, ts}, fs}, rest} True{}: invariant(f, rest, fixed, invariant(f, [x], fixed, True{})) case 1n+f Con{Lint.Node{Lint.Construction{t}, n, s, k, fs}, rest} True{}: invariant(f, rest, fixed, invariant(f, k, fixed, True{})) case 1n+f Con{x, rest} True{}: False{} Uses (8): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.contains https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=bend-lint-api@0.2.0.0/linter/lint.bend&name=Node https://jend.leeeet.dev/definition.txt?path=bend-lint-api@0.2.0.0/linter/lint.bend&name=Syntax