Update 3.6.4.4阶段四:高阶函数.md
优化
This commit is contained in:
@@ -112,9 +112,12 @@ def is_prime(n):
|
||||
```
|
||||
|
||||
需求:
|
||||
你需要通过自己写一个函数: `count_cond` ,来接受一个含有两个参数的函数 `condition(n, i)`(使用lambda表达式)
|
||||
|
||||
你需要通过自己写一个函数: `count_cond` ,来接受一个含有两个参数的函数 `condition(n, i)`(使用lambda表达式),
|
||||
|
||||
且`condition`函数应该满足第一个参数为N,而第二个参数将会在`condition`函数中遍历 1 to N。
|
||||
`count_cond` 将返回一个单参数函数(ps:一个匿名函数),此单参数函数将会在被调用时返回 1 to N 中所有满足`condition`的数字(如:素数,因数)。
|
||||
|
||||
`count_cond` 将返回一个单参数函数(ps:一个匿名函数),此单参数函数将会在被调用时返回 1 to N 中所有满足`condition`的数字的个数(如:1到n中素数的个数)。
|
||||
|
||||
```python
|
||||
def count_cond(condition):
|
||||
|
||||
Reference in New Issue
Block a user