Using map in Haskell

For people new to functional programming map may be one of the first concepts that they struggle with. map is a function that takes two parameters: a function and a list of elements. The type signature of map is (a -> b) -> [a] -> [b]. The (a -> b) part is the function you pass to map, we will call it f. f takes one value and … Read more

Mapping over values in a python dictionary

There is no such function; the easiest way to do this is to use a dict comprehension: In python 2.7, use the .iteritems() method instead of .items() to save memory. The dict comprehension syntax wasn’t introduced until python 2.7. Note that there is no such method on lists either; you’d have to use a list comprehension or the map() function. As … Read more