Additional functions on Lean.NameMap
. #
We provide NameMap.filter
and NameMap.filterMap
.
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
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}
(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