Perm.insert_by: def of bend-mathlib@0.8.1.0 Import: import bend-mathlib@0.8.1.0/perm.bend as Perm Lines 67-73 of bend-mathlib@0.8.1.0/perm.bend: https://jend.leeeet.dev/read.txt?path=bend-mathlib@0.8.1.0/perm.bend&start_line=67&end_line=73 import Base # Insertion into a list, generic comparator (structural, Base-only branching via Bool.pick). def insert_by(~A: Data, ~le: A -> A -> Bool, +x: A, xs: List<&2, A>) -> List<&2, A>: match xs: case Nil{}: x <> Nil{} case +y <> +t: Bool.pick(List<&2, A>, le(x, y), x <> y <> t, y <> insert_by(~A, ~le, x, t)) Uses (3): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List