blob: 21a809288fd86146c63e61b99bca0c2dfd315aea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from test_utils import simple_assert
def pipe(x, fns):
"""Apply `x` to the first function in `fns` and then use its output as the
input for the next function in the list."""
result = x
for f in fns:
result = f(result)
return result
actual = pipe(10, [
lambda x: x + 3,
lambda x: x - 1,
lambda x: x * 2,
])
expected = (((10 + 3) - 1) * 2)
simple_assert(actual, expected, name="pipe")
|