Category
suspicious
Shape
String.length(s) / List.len(xs) (or a hand-rolled count) only to feed fuel for a walk of that same s/xs, when the walk can be structurally recursive on the value itself.
fuel (U006) flags a literal Nat in a fuel-named parameter. This would flag deriving fuel from a full length walk of the value about to be walked again.
Bad
def escape_loop(fuel: Nat, s: String, acc: List<&2, Char>) -> String:
match fuel:
case 0n:
String.from_list(List.reverse(&2, Char, acc))
case 1n++p:
match s:
case SNil{}:
String.from_list(List.reverse(&2, Char, acc))
case SCon{c, t}:
escape_loop(p, t, c <> acc)
def escape(s: String) -> String:
escape_loop(String.length(s), s, [])
Good
def escape(s: String, acc: List<&2, Char>) -> String:
match s:
case SNil{}:
String.from_list(List.reverse(&2, Char, acc))
case SCon{c, t}:
escape(t, c <> acc)
Category
suspiciousShape
String.length(s)/List.len(xs)(or a hand-rolled count) only to feedfuelfor a walk of that sames/xs, when the walk can be structurally recursive on the value itself.fuel(U006) flags a literal Nat in a fuel-named parameter. This would flag deriving fuel from a full length walk of the value about to be walked again.Bad
Good