17 函数式与内置函数

def test():
    print ('in the test1')
def test():
    print ('in the test')
    return test1
res=test()
print(res())

#result:
in the test 
in the test1
None

匿名函数

lambda x:x+1
def calc(x):
    return x+1

func=lambda x:x+1
print(func(10))

lambda x,y,z:(x+1,y+1,z+1)


函数式编程
三种编程方法论:面向过程 函数式 面向对象
函数式=编程语言定义的函数+数学意义的函数(最早出现)
不可变 不用变量保存状态 不修改变量

高阶函数:把函数当做参数传给另外一个函数
返回值中包含函数

尾调用 在函数最后一步调用另外一个函数


猜你喜欢

转载自www.cnblogs.com/louzhiyuan/p/10393031.html