Skip to content

Commit 5fc7603

Browse files
committed
Some more corrections
- ~list~ cast isn't required since we dont actually have a list after reduce anyway - spelling
1 parent 647e5f9 commit 5fc7603

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

_posts/2015-10-18-introduction-to-functional-programming-in-python-p1.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,17 @@ from functools import reduce
6363

6464
def f_average(nums):
6565
"""
66-
The same as the calc_averaage function, just in a functional style
66+
The same as the calc_average function, just in a functional style
6767
"""
6868
sum = reduce(lambda x, y: x + y, nums, 0)
6969

70-
return list(sum/len(nums))
70+
return sum/len(nums)
7171
{% endhighlight %}
7272

7373
> Python 2.7.x Differences
7474
>
7575
> The ```reduce``` function was only moved into ```functools``` in Python > 3.0 so
76-
> it doesn't need to be imported. Also the result doesn't require being cast to
77-
> a list.
76+
> it doesn't need to be imported.
7877
7978
Don't worry too much if you don't understand the code above we will get around to how exactly
8079
this works in later posts, the important point is to note that this style is slightly more

0 commit comments

Comments
 (0)