Skip to content

Commit e186d89

Browse files
authored
Update README.md
1 parent b408dde commit e186d89

File tree

1 file changed

+3
-3
lines changed
  • source/books/python/80-functional/10-higher-order-function/20-filter

1 file changed

+3
-3
lines changed

source/books/python/80-functional/10-higher-order-function/20-filter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ list(filter(not_empty, ['A', '', 'B', None, 'C', ' ']))
2626

2727
可见用`filter()`这个高阶函数,关键在于正确实现一个“筛选”函数。
2828

29-
注意到`filter()`函数返回的是一个`Iterator`,也就是一个惰性序列,所以要强迫`filter()`完成计算结果,需要用`list()`函数获得所有结果并返回list
29+
注意到`filter()`函数返回的是一个`Iterator`,也就是一个惰性序列,所以要强迫`filter()`完成计算结果,需要用`list()`函数获得所有结果并返回`list`
3030

3131
### 用filter求素数
3232

@@ -86,15 +86,15 @@ def primes():
8686
由于`primes()`也是一个无限序列,所以调用时需要设置一个退出循环的条件:
8787

8888
```python
89-
# 打印1000以内的素数:
89+
# 打印100以内的素数:
9090
for n in primes():
9191
if n < 100:
9292
print(n)
9393
else:
9494
break
9595
```
9696

97-
注意到`Iterator`是惰性计算的序列,所以我们可以用Python表示“全体自然数”,“全体素数”这样的序列,而代码非常简洁
97+
注意到`Iterator`是惰性计算的序列,所以我们可以用Python表示“全体自然数”,“全体素数”这样的序列,代码却非常简洁
9898

9999
### 练习
100100

0 commit comments

Comments
 (0)