Equations
- Maps.format' [] = Std.Format.text ""
- Maps.format' [m] = Std.format (Std.format "[" ++ Std.format m ++ Std.format "]")
- Maps.format' (m :: rest) = Std.format (Std.format "[" ++ Std.format m ++ Std.format "]" ++ Std.format Std.Format.line) ++ Maps.format' rest
Instances For
@[implicit_reducible]
instance
instToFormatMapsOfMap
{α : Type u_1}
{β : Type u_2}
[Std.ToFormat (Map α β)]
:
Std.ToFormat (Maps α β)
Equations
- instToFormatMapsOfMap = { format := Maps.format' }
Equations
- Maps.values [] = []
- Maps.values (m :: mrest) = m.values ++ Maps.values mrest
Instances For
Get the newest map (i.e., from the beginning) in ms.
Equations
- Maps.newest [] = []
- Maps.newest (m :: mrest) = m
Instances For
Flatten the Maps ms to get a single map.
Searching for (x : α) after flattening will proceed from the newest to
the oldest Map.
Equations
- ms.toSingleMap = List.flatten ms
Instances For
Look up (x : α) in all the maps in ms.
Equations
- Maps.find? [] x = none
- Maps.find? (m :: rest) x = match m.find? x with | none => Maps.find? rest x | some v => some v
Instances For
Look up (x : α) in all the maps in ms, returning the default element d if
x is not found.
Equations
- Maps.findD [] x d = d
- Maps.findD (m :: rest) x d = match m.find? x with | none => Maps.findD rest x d | some v => v
Instances For
Remove x and its associated value from ms.
Equations
- Maps.remove [] x = []
- Maps.remove (m :: mrest) x = m.erase x :: Maps.remove mrest x
Instances For
def
Maps.update
{α : Type u_1}
{β : Type u_2}
[DecidableEq α]
(ms : Maps α β)
(x : α)
(v : β)
:
Maps α β
Update x with v in ms. Do nothing if x is not in ms.
Equations
Instances For
def
Maps.insert
{α : Type u_1}
{β : Type u_2}
[DecidableEq α]
(ms : Maps α β)
(x : α)
(v : β)
:
Maps α β
Insert (x, v) in ms. If x is already in ms, update that entry.
Else add it to the most recent map.
Equations
Instances For
def
Maps.insertInOldest
{α : Type u_1}
{β : Type u_2}
[DecidableEq α]
(ms : Maps α β)
(x : α)
(v : β)
:
Maps α β
Insert (x, v) in the oldest map in ms. Do nothing if x is already in ms.
Equations
- ms.insertInOldest x v = Maps.insertInOldest.go✝ x v [] ms
Instances For
def
Maps.addInOldest
{α : Type u_1}
{β : Type u_2}
[DecidableEq α]
(ms : Maps α β)
(xs : List α)
(vs : List β)
:
Maps α β
Insert (xi, vi) -- where xi and vi are corresponding elements of xs and
vs -- in the oldest map in ms, only if xi is not in ms.
Equations
- ms.addInOldest [] vs = ms
- ms.addInOldest xs [] = ms
- ms.addInOldest (x :: xrest) (v :: vrest) = (ms.insertInOldest x v).addInOldest xrest vrest