Functional Python Programming
The Itertools Module We can—with a small change—use the random.randrange(c) method instead of the cycle(c) method to achieve a r ...
Chapter 8 Using the finite iterators The itertools module provides a number of functions that we can use to produce finite seque ...
The Itertools Module Assigning numbers with enumerate() In Chapter 7, Additional Tuple Techniques, we used the enumerate() funct ...
Chapter 8 The first Leg function is a short trip between two points on the Chesapeake Bay. We can add a function that will build ...
The Itertools Module One application of running totals is quartiling data. We can compute the running total for each sample and ...
Chapter 8 Combining iterators with chain() We can use the chain() function to combine a collection of iterators into a single, o ...
The Itertools Module Partitioning an iterator with groupby() We can use the groupby() function to partition an iterator into sma ...
Chapter 8 We created a defaultdict class with a list object as the value associated with each key. Each item will have the given ...
The Itertools Module In the Reiterating a cycle with cycle() section of this chapter, we looked at data selection using a simple ...
Chapter 8 We can create pairs using list slices as follows: zip(flat[0::2], flat[1::2]) The islice() function gives us similar c ...
The Itertools Module We can use these with file parsing to skip headers or footers in the input. We use the dropwhile() function ...
Chapter 8 Two approaches to filtering with filterfalse() and filter() In Chapter 5, Higher-order Functions we looked at the buil ...
The Itertools Module Applying a function to data via starmap() and map() The built-in map() function is a higher-order function ...
Chapter 8 make_leg = lambda start, end: Leg(start, end, haversine(start,end)) trip = list(starmap(make_leg, pair_iter)) The legs ...
The Itertools Module The itertools recipes The itertools chapter of the Python library documentation, Itertools Recipes, is outs ...
Chapter 8 Function Name Arguments Results dotproduct (vec1, vec2) This is the essential definition of a dot product. Multiply tw ...
The Itertools Module We've also looked at a number of finite iterators. Some of these are built-in and some of these are part of ...
More Itertools Techniques Functional programming emphasizes stateless programming. In Python, this leads us to work with generat ...
More Itertools Techniques These functions embody algorithms that iterate over potentially large result sets from small collectio ...
Chapter 9 In some cases, we don't have a simple Boolean matching function. Instead, we're forced to search for a minimum or maxi ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf