mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-28 02:23:44 +03:00
[ new ] popping key-value pair from a SortedMap
This commit is contained in:
parent
5f7ad73a35
commit
692e389bb8
@ -333,6 +333,13 @@ export
|
||||
min : SortedMap k v -> Maybe (k, v)
|
||||
min Empty = Nothing
|
||||
min (M _ t) = Just (treeMin t)
|
||||
|
||||
export
|
||||
pop : SortedMap k v -> Maybe ((k, v), SortedMap k v)
|
||||
pop m = do
|
||||
(k, v) <- min m
|
||||
pure ((k, v), delete k m)
|
||||
|
||||
export
|
||||
(Show k, Show v) => Show (SortedMap k v) where
|
||||
show m = "fromList " ++ (show $ SortedMap.toList m)
|
||||
|
Loading…
Reference in New Issue
Block a user