Functional Programming Tools: filter,,# 'filter(fu
Functional Programming Tools: filter,,# 'filter(fu
# 'filter(function, sequence)' returns a sequence consisting of those items from # the sequence for which function(item) is true. If sequence is a string or tuple, # the result will be of the same type; otherwise, it is always a list. # For example, to compute some primes:def f(x): return x % 2 != 0 and x % 3 != 0print filter(f, range(2, 25))
相关内容
- Convert Float number,convertfloat,print str(3.
- A generator function: creates its objects on the fly.,generatorcrea
- in function demo,functiondemo,name = 'ABCD
- Copy a dictionary,copydictionary,L = [1,2,3]D
- len() function,lenfunction,message = ra
- Built-in function len(): get the length of a list,built-inlen,a = [
- next() raises a StopIteration exception tellint the for loop to termi
- Assigning Consecutive Values,,print range(
- Functional Programming Tools: reduce 2,functionalreduce,# If there'
- Input and Output: repr(): generate representations which can be read
评论关闭