Functional Python Programming
The PyMonad Library For Mac OS and Linux developers, the command pip install PyMonad or easy_install-3.3 pymonad must be run usi ...
Chapter 14 Let's look at a concrete example in Python, for example, we have a function like the following one: from pymonad impo ...
The PyMonad Library This is similar in some respects to the functools.partial() function. The important difference is that curry ...
Chapter 14 The myreduce() function will behave like the built-in reduce() function. The myreduce() function works with an iterab ...
The PyMonad Library Currying the hard way We can create curried functions manually, without using the decorator from the pymonad ...
Chapter 14 Here's our first function that computes the product: import operator prod = myreduce(operator.mul) This is based on o ...
The PyMonad Library This will define a version of the sum() function that works with infinite sequences, stopping the generation ...
Chapter 14 There are two subclasses of the Maybe functor: Nothing Just(some simple value) We use Nothing as a stand-in for the ...
The PyMonad Library Here's the comparison: list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] List(range(10)) [range(0, ...
Chapter 14 Since a List object is a functor, we can map functions to the List object. The function is applied to each item in th ...
The PyMonad Library We can now map the / operator to the map() and operator.truediv parallel functors: 2*sum(map(operator.tru ...
Chapter 14 Python, as we have seen, is strict. It doesn't require monads. We can, however, still apply the concept in places whe ...
The PyMonad Library There's a lot of very strange gambling terminology involved. We can't provide much background about the vari ...
Chapter 14 The preceding function will generate a pair of dice for us. Here's our expectation from the overall game: def craps() ...
The PyMonad Library We rolled the dice once to determine if we have a first-roll win, loss, or point. We return an appropriate m ...
Chapter 14 The final monad has a string that shows the outcome. It has the point that was established and the sequence of dice r ...
The PyMonad Library Summary In this chapter, we looked at how we can use the PyMonad library to express some functional programm ...
A Functional Approach to Web Services We'll step away from Exploratory Data Analysis and look closely at web servers and web ser ...
A Functional Approach to Web Services In order to avoid details of a specific web framework, we'll focus on the Web Server Gatew ...
Chapter 15 The techniques for a user agent to handle 3xx and 401 codes aren't deeply stateful. A simple recursion can be used. I ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf