Working With Data Structures
Earlier we outlined and worked with several different types of data structures. Let's take a closer look at some ways
-
Working With Data StructuresEXERCISE: Map, Filter, Reduce
We have a program that starts with a list of objects read from a file. Using the built-in functions available in the
Enum
andMap
modules, filter out "inactive" items (objects where the "active" attribute is nottrue
), and then log a list of object names to the console. -
Working With Data StructuresTaming List Enumeration with Comprehensions
Often we find ourselves looping over something enumerable, mapping values into another list, and potentially filtering out some unwanted items. Comprehensions use a generator and a filter to provide some excellent syntactic sugar for this kind of task.
-
Working With Data StructuresEXERCISE: Comprehensions
Take another pass at the previous exercise, and use a comprehension to devise a concise solution.
-
Working With Data StructuresLunch
Break for Lunch