Documentation

CslibFrontier.Foundations.Data.List.CollisionReplace

Scanning for a collision #

Main results #

theorem List.foldl_replaceOnCollision {α : Type u_1} [DecidableEq α] (xs : List α) (p r : α) :
foldl (fun (current x : α) => if current = x then p else current) r xs = if r ∈ xs then p else r

A scan returns p when the original candidate collides, and retains the candidate otherwise. Once replaced, the value stays p.