Functional Python Programming
Working with Collections Recall that zip() truncates the sequence at the shortest list. This means that, if the list is not an e ...
Chapter 4 The reversed() function produces an iterable, but the argument value must be a sequence object. The function then yiel ...
Working with Collections Summary In this chapter, we saw detailed ways to use a number of built-in reductions. We've used any() ...
Higher-order Functions A very important feature of the functional programming paradigm is higher-order functions. These are func ...
Higher-order Functions In this chapter, we'll look at the following functions: max() and min() Lambda forms that we can use to ...
Chapter 5 They also do something more sophisticated. Let's say we have our trip data from the examples in Chapter 4, Working wit ...
Higher-order Functions We've used a generator function to extract the relevant item from each leg of the trip tuple. We've had t ...
Chapter 5 The by_dist() function picks apart the three items in each leg tuple and returns the distance item. We'll use this wit ...
Higher-order Functions We can also assign lambdas to variables, by doing something like this: start= lambda x: x[0] end = lambda ...
Chapter 5 Lambdas and the lambda calculus In a book on a purely functional programming language, it would be necessary to explai ...
Higher-order Functions This will split the text into lines. For each line, it will split the line into space-delimited words and ...
Chapter 5 We've done the same processing on each item in the generator expression. The important difference between the map() fu ...
Higher-order Functions We've created a sequence of pairs drawn from a single flat list. Each pair will have two adjacent values. ...
Chapter 5 filterfalse() as variations on this theme. Refer to Chapter 8, The Itertools Module to understand the usage of the ite ...
Higher-order Functions We often want to use the filter() function with defined functions instead of lambda forms. The following ...
Chapter 5 Given the statistics, we used the outlier lambda to filter our data. If the normalized value is too large, the data is ...
Higher-order Functions Using sorted() to put data in order When we need to produce results in a defined order, Python gives us t ...
Chapter 5 Writing higher-order functions We can identify three varieties of higher-order functions; they are as follows: Functi ...
Higher-order Functions The generator expression: (f(x) for x in C) The generator function: def mymap(f, C): for x in C: yield ...
Chapter 5 We need to exercise some caution when designing mappings that combine too many transformations in a single function. A ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf