Logo

Programming-Idioms

History of Idiom 170 > diff from v12 to v13

Edit summary for version 13 by cercerilla:
New Haskell implementation by user [cercerilla]

Version 12

2019-01-02, 11:03:15

Version 13

2019-09-26, 14:28:25

Idiom #170 Get map size

Set n to the number of elements stored in mymap.

This is not always equal to the map capacity.

Idiom #170 Get map size

Set n to the number of elements stored in mymap.

This is not always equal to the map capacity.

Extra Keywords
length count
Extra Keywords
length count
Imports
import qualified Data.Map as Map
Code
getMapSize :: Map.Map k v -> Int
getMapSize m = Map.size m
Comments bubble
The eta-reduced version would simply be: getMapSize = Map.size
Doc URL
https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Lazy.html#g:10