Additional functions on Lean.NameMap
. #
We provide NameMap.filter
and NameMap.filterMap
.
instance
Lean.NameMap.instForInProdName_batteries
{m : Type u_1 → Type u_2}
{β : Type}
:
ForIn m (Lean.NameMap β) (Lean.Name × β)
Equations
- Lean.NameMap.instForInProdName_batteries = inferInstanceAs (ForIn m (Lean.RBMap Lean.Name β Lean.Name.quickCmp) (Lean.Name × β))
filter f m
returns the NameMap
consisting of all
"key
/val
"-pairs in m
where f key val
returns true
.
Equations
Instances For
def
Lean.NameMap.filter.process
{α : Type}
(f : Lean.Name → α → Bool)
(r : Lean.NameMap α)
(n : Lean.Name)
(i : α)
:
Equations
- Lean.NameMap.filter.process f r n i = if f n i = true then r.insert n i else r
Instances For
def
Lean.NameMap.filterMap
{α : Type}
{β : Type}
(f : Lean.Name → α → Option β)
(m : Lean.NameMap α)
:
filterMap f m
allows to filter a NameMap
and simultaneously modify the filtered values.
It takes a function f : Name → α → Option β
and applies f name
to the value with key name
.
The resulting entries with non-none
value are collected to form the output NameMap
.
Equations
Instances For
def
Lean.NameMap.filterMap.process
{α : Type}
{β : Type}
(f : Lean.Name → α → Option β)
(r : Lean.NameMap β)
(n : Lean.Name)
(i : α)
:
Equations
- Lean.NameMap.filterMap.process f r n i = match f n i with | none => r | some b => r.insert n b