map :: (a -> b) -> IntMap a -> IntMap b

containers -Data.IntMap.Lazy  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (a -> b) -> IntMap a -> IntMap b

containers -Data.IntMap.Strict  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (Key -> Key) -> IntSet -> IntSet

containers -Data.IntSet  

<p><em>O(n*min(n,W))</em>. <code><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntSet%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> f s</code> is the set obtained by applying <code>f</code> to each element of <code>s</code>.</p><p>It's worth noting that the size of the result may be smaller if, for some <code>(x,y)</code>, <code>x /= y && f x == f y</code></p>
map :: (a -> b) -> Map k a -> Map k b

containers -Data.Map.Lazy  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (a -> b) -> Map k a -> Map k b

containers -Data.Map.Strict  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: Ord b => (a -> b) -> Set a -> Set b

containers -Data.Set  

<p><em>O(n*log n)</em>. <code><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Set%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> f s</code> is the set obtained by applying <code>f</code> to each element of <code>s</code>.</p><p>It's worth noting that the size of the result may be smaller if, for some <code>(x,y)</code>, <code>x /= y && f x == f y</code></p>

containers -Data.Map.Lazy  

<p>A Map from keys <code>k</code> to values <code>a</code>.</p>

containers -Data.Map.Strict  

<p>A Map from keys <code>k</code> to values <code>a</code>.</p>

containers -Data.Map  

<div class="doc"><p><em>Note:</em> You should use <a href="/?query=%28%28name%3A%28%21Data.Map.Strict%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data.Map.Strict%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Data.Map.Strict%29">Data.Map.Strict</a> instead of this module if:</p><ul><li>You will eventually need all the values stored.</li><li>The stored values don't represent large virtual data structures to be lazily computed.</li></ul><p>An efficient implementation of ordered maps from keys to values (dictionaries).</p><p>These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.</p><pre> import qualified Data.Map as Map</pre><p>The implementation of <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> is based on <em>size balanced</em> binary trees (or trees of <em>bounded balance</em>) as described by:</p><ul><li>Stephen Adams, "<em>Efficient sets: a balancing act</em>", Journal of Functional Programming 3(4):553-562, October 1993, <a href="http://www.swiss.ai.mit.edu/~adams/BB/">http://www.swiss.ai.mit.edu/~adams/BB/</a>.<ul><li>J. Nievergelt and E.M. Reingold, "<em>Binary search trees of bounded balance</em>", SIAM journal of computing 2(1), March 1973.</li></ul></li></ul><p>Note that the implementation is <em>left-biased</em> -- the elements of a first argument are always preferred to the second, for example in <code><a href="/?query=%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21union%29">union</a></code> or <code><a href="/?query=%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21insert%29">insert</a></code>.</p><p><em>Warning</em>: The size of the map must not exceed <code>maxBound::Int</code>. Violation of this condition is not detected and if the size limit is exceeded, its behaviour is undefined.</p><p>Operation comments contain the operation time complexity in the Big-O notation (<a href="http://en.wikipedia.org/wiki/Big_O_notation">http://en.wikipedia.org/wiki/Big_O_notation</a>).</p></div>

containers -Data.Map.Strict  

<div class="doc"><p>An efficient implementation of ordered maps from keys to values (dictionaries).</p><p>API of this module is strict in both the keys and the values. If you need value-lazy maps, use <a href="/?query=%28%28name%3A%28%21Data.Map.Lazy%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data.Map.Lazy%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Data.Map.Lazy%29">Data.Map.Lazy</a> instead. The <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> type is shared between the lazy and strict modules, meaning that the same <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> value can be passed to functions in both modules (although that is rarely needed).</p><p>These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.</p><pre> import qualified Data.Map.Strict as Map</pre><p>The implementation of <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> is based on <em>size balanced</em> binary trees (or trees of <em>bounded balance</em>) as described by:</p><ul><li>Stephen Adams, "<em>Efficient sets: a balancing act</em>", Journal of Functional Programming 3(4):553-562, October 1993, <a href="http://www.swiss.ai.mit.edu/~adams/BB/">http://www.swiss.ai.mit.edu/~adams/BB/</a>.<ul><li>J. Nievergelt and E.M. Reingold, "<em>Binary search trees of bounded balance</em>", SIAM journal of computing 2(1), March 1973.</li></ul></li></ul><p>Note that the implementation is <em>left-biased</em> -- the elements of a first argument are always preferred to the second, for example in <code><a href="/?query=%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21union%29">union</a></code> or <code><a href="/?query=%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21insert%29">insert</a></code>.</p><p><em>Warning</em>: The size of the map must not exceed <code>maxBound::Int</code>. Violation of this condition is not detected and if the size limit is exceeded, its behaviour is undefined.</p><p>Operation comments contain the operation time complexity in the Big-O notation (<a href="http://en.wikipedia.org/wiki/Big_O_notation">http://en.wikipedia.org/wiki/Big_O_notation</a>).</p><p>Be aware that the <code><a href="/?query=%28%28name%3A%28%21Functor%29%20package%3A%28%21base%29%20module%3A%28%21Control.Monad%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Functor%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21Functor%29">Functor</a></code>, <code>Traversable</code> and <code>Data</code> instances are the same as for the <a href="/?query=%28%28name%3A%28%21Data.Map.Lazy%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data.Map.Lazy%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Data.Map.Lazy%29">Data.Map.Lazy</a> module, so if they are used on strict maps, the resulting maps will be lazy.</p></div>

containers -Data.Map.Lazy  

<div class="doc"><p>An efficient implementation of ordered maps from keys to values (dictionaries).</p><p>API of this module is strict in the keys, but lazy in the values. If you need value-strict maps, use <a href="/?query=%28%28name%3A%28%21Data.Map.Strict%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data.Map.Strict%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Data.Map.Strict%29">Data.Map.Strict</a> instead. The <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> type itself is shared between the lazy and strict modules, meaning that the same <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> value can be passed to functions in both modules (although that is rarely needed).</p><p>These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.</p><pre> import qualified Data.Map.Lazy as Map</pre><p>The implementation of <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> is based on <em>size balanced</em> binary trees (or trees of <em>bounded balance</em>) as described by:</p><ul><li>Stephen Adams, "<em>Efficient sets: a balancing act</em>", Journal of Functional Programming 3(4):553-562, October 1993, <a href="http://www.swiss.ai.mit.edu/~adams/BB/">http://www.swiss.ai.mit.edu/~adams/BB/</a>.<ul><li>J. Nievergelt and E.M. Reingold, "<em>Binary search trees of bounded balance</em>", SIAM journal of computing 2(1), March 1973.</li></ul></li></ul><p>Note that the implementation is <em>left-biased</em> -- the elements of a first argument are always preferred to the second, for example in <code><a href="/?query=%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21union%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21union%29">union</a></code> or <code><a href="/?query=%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21insert%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21insert%29">insert</a></code>.</p><p><em>Warning</em>: The size of the map must not exceed <code>maxBound::Int</code>. Violation of this condition is not detected and if the size limit is exceeded, its behaviour is undefined.</p><p>Operation comments contain the operation time complexity in the Big-O notation (<a href="http://en.wikipedia.org/wiki/Big_O_notation">http://en.wikipedia.org/wiki/Big_O_notation</a>).</p></div>
showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String

containers -Data.Map.Lazy  

<p><em>O(n)</em>. The expression (<code><code><a href="/?query=%28%28name%3A%28%21showTreeWith%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21showTreeWith%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21showTreeWith%29">showTreeWith</a></code> showelem hang wide map</code>) shows the tree that implements the map. Elements are shown using the <code>showElem</code> function. If <code>hang</code> is <code><a href="/?query=%28%28name%3A%28%21True%29%20package%3A%28%21base%29%20module%3A%28%21Data.Bool%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21True%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21True%29">True</a></code>, a <em>hanging</em> tree is shown otherwise a rotated tree is shown. If <code>wide</code> is <code><a href="/?query=%28%28name%3A%28%21True%29%20package%3A%28%21base%29%20module%3A%28%21Data.Bool%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21True%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21True%29">True</a></code>, an extra wide version is shown.</p><pre> Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]] Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t (4,()) +--(2,()) | +--(1,()) | +--(3,()) +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t (4,()) | +--(2,()) | | | +--(1,()) | | | +--(3,()) | +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t +--(5,()) | (4,()) | | +--(3,()) | | +--(2,()) | +--(1,())</pre>
showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String

containers -Data.Map.Strict  

<p><em>O(n)</em>. The expression (<code><code><a href="/?query=%28%28name%3A%28%21showTreeWith%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21showTreeWith%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21showTreeWith%29">showTreeWith</a></code> showelem hang wide map</code>) shows the tree that implements the map. Elements are shown using the <code>showElem</code> function. If <code>hang</code> is <code><a href="/?query=%28%28name%3A%28%21True%29%20package%3A%28%21base%29%20module%3A%28%21Data.Bool%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21True%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21True%29">True</a></code>, a <em>hanging</em> tree is shown otherwise a rotated tree is shown. If <code>wide</code> is <code><a href="/?query=%28%28name%3A%28%21True%29%20package%3A%28%21base%29%20module%3A%28%21Data.Bool%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21True%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21True%29">True</a></code>, an extra wide version is shown.</p><pre> Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]] Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t (4,()) +--(2,()) | +--(1,()) | +--(3,()) +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t (4,()) | +--(2,()) | | | +--(1,()) | | | +--(3,()) | +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t +--(5,()) | (4,()) | | +--(3,()) | | +--(2,()) | +--(1,())</pre>
foldlWithKey :: (a -> Key -> b -> a) -> a -> IntMap b -> a

containers -Data.IntMap.Lazy  

<p><em>O(n)</em>. Fold the keys and values in the map using the given left-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldlWithKey%29">foldlWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldl%29">foldl</a></code> (\z' (kx, x) -> f z' kx x) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys = reverse . foldlWithKey (\ks k x -> k:ks) []</pre><pre>let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"</pre>
foldrWithKey :: (Key -> a -> b -> b) -> b -> IntMap a -> b

containers -Data.IntMap.Lazy  

<p><em>O(n)</em>. Fold the keys and values in the map using the given right-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldrWithKey%29">foldrWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldr%29">foldr</a></code> (<code><a href="/?query=%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%20module%3A%28%21Data.Tuple%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21uncurry%29">uncurry</a></code> f) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys map = foldrWithKey (\k x ks -> k:ks) [] map</pre><pre>let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"</pre>
foldlWithKey :: (a -> Key -> b -> a) -> a -> IntMap b -> a

containers -Data.IntMap.Strict  

<p><em>O(n)</em>. Fold the keys and values in the map using the given left-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldlWithKey%29">foldlWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldl%29">foldl</a></code> (\z' (kx, x) -> f z' kx x) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys = reverse . foldlWithKey (\ks k x -> k:ks) []</pre><pre>let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"</pre>
foldrWithKey :: (Key -> a -> b -> b) -> b -> IntMap a -> b

containers -Data.IntMap.Strict  

<p><em>O(n)</em>. Fold the keys and values in the map using the given right-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldrWithKey%29">foldrWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldr%29">foldr</a></code> (<code><a href="/?query=%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%20module%3A%28%21Data.Tuple%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21uncurry%29">uncurry</a></code> f) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntMap.Strict%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys map = foldrWithKey (\k x ks -> k:ks) [] map</pre><pre>let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"</pre>
foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a

containers -Data.Map.Lazy  

<p><em>O(n)</em>. Fold the keys and values in the map using the given left-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldlWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldlWithKey%29">foldlWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldl%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldl%29">foldl</a></code> (\z' (kx, x) -> f z' kx x) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys = reverse . foldlWithKey (\ks k x -> k:ks) []</pre><pre>let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"</pre>
foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b

containers -Data.Map.Lazy  

<p><em>O(n)</em>. Fold the keys and values in the map using the given right-associative binary operator, such that <code><code><a href="/?query=%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldrWithKey%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21foldrWithKey%29">foldrWithKey</a></code> f z == <code><a href="/?query=%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21foldr%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21foldr%29">foldr</a></code> (<code><a href="/?query=%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%20module%3A%28%21Data.Tuple%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21uncurry%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21uncurry%29">uncurry</a></code> f) z . <code><a href="/?query=%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Map.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toAscList%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21toAscList%29">toAscList</a></code></code>.</p><p>For example,</p><pre>keys map = foldrWithKey (\k x ks -> k:ks) [] map</pre><pre>let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"</pre>

containers -Data.Map.Lazy  Data.Map.Strict  

<p><em>O(1)</em>. Is the map empty?</p><pre>Data.Map.null (empty) == True Data.Map.null (singleton 1 'a') == False</pre>