seen from Canada
seen from Malaysia

seen from United States

seen from United States

seen from United States
seen from Canada

seen from United States
seen from Brazil
seen from China

seen from Canada
seen from Ireland

seen from Moldova
seen from China
seen from United States
seen from United States
seen from Vietnam

seen from Argentina
seen from United States
seen from South Korea

seen from Sri Lanka

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Python的内置函数 - lambda, filter, reduce, map
参考:python document 2.7.5
1. lambda function
在Python里lambda是用于构建函数的工具。区别于def,但lambda构建的函数只能被执行一次,而且lambda只能包含单一的表达式。lambda更类似于functional programming的概念,可以用于任何需要使用函数的地方。
Lambda函数中,不能使用statement,必须有返回值(即便是返回null的函数),也可以使用条件表达式。
简单的例子
def g(x):
return x ** 2
等同于
g = lambda x: x ** 2
换句话说,lambda不是必须的,所有的lambda都可以用def来代替,只是使用lambda的话会让代码更简洁一些。
2. filter(function, iterable)
等同于[item for item in iterable if function(item)]
函数的功能是构建一个列表,其元素为原内容通过函数运算后返回为真值的部分,用于可迭代的序列或者容器等。除了对象是字符串或者元组返回对应类型外,其余返回类型都是列表。
例如:
filter可以结合lambda函数,完成去掉一个列表里的某个值元素(这个操作可以去掉相同值的多个元素,而list.remove(element)只能去掉其中的第一个)。
list_filtered = filter(lambda a: a!= value, list_original)
3. reduce(function, iterable[, initializer])
对可迭代类型的元素迭代调用函数。如果没有赋初始值,则传递顺序为:
第一和第二个元素进行函数操作,结果作为新元素和下一个元素(也就是原来的第三个元素)继续进行操作,以此类推。
同样可以和lambda合用
例如
reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) 也就是用来计算((((1+2)+3)+4)+5)。
4. map(function, iterable, ...)
将函数用于对象的每一个元素中,返回一个包含每一个结果的列表。
同样也可以和lambda函数合用
例如
map(lambda x:x ** 2, range(1,11))
返回的是[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
❥❥ staircase design idea to combine it with a library

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Article by at 2011-01-17 07:34:10 Categorized in Apple Trackpad,
Article by at 2011-01-17 07:34:10 Categorized in Apple Trackpad,