Skip to content

Commit

Permalink
chore: fix implicitness in HashMap.ofList
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed May 22, 2024
1 parent 2faa81d commit 8b02950
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Lean/Data/HashMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def toArray (m : HashMap α β) : Array (α × β) :=
def numBuckets (m : HashMap α β) : Nat :=
m.val.buckets.val.size

variable [BEq α] [Hashable α]

/-- Builds a `HashMap` from a list of key-value pairs. Values of duplicated keys are replaced by their respective last occurrences. -/
def ofList (l : List (α × β)) : HashMap α β :=
l.foldl (init := HashMap.empty) (fun m p => m.insert p.fst p.snd)
Expand All @@ -260,6 +262,7 @@ def ofListWith (l : List (α × β)) (f : β → β → β) : HashMap α β :=
match m.find? p.fst with
| none => m.insert p.fst p.snd
| some v => m.insert p.fst $ f v p.snd)

end Lean.HashMap

/--
Expand Down

0 comments on commit 8b02950

Please sign in to comment.