函数式编程

时间:2018-03-29 22:18:35   收藏:0   阅读:208

编程的三种方法论:

1面向过程

2函数式

3面向对象

---------------------------------------------

#把函数当做参数传给另一个函数
def foo(n):
print(n)

def bar(name):
print(‘my name is %s‘ %name)

foo(bar(‘alex‘))
输出结果:
my name is alex
None


------------------------

#返回值当中包含函数
def bar():
print(‘from bar‘)
def foo():
print(‘from foo‘)
return bar
n = foo()
n()

def handle():
print(‘from handle‘)
return handle
h = handle()
h()

def test1():
print(‘from test1‘)

def test():
print(‘from handle‘)
return test1()
test()

原文:https://www.cnblogs.com/lhqlhq/p/8672368.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!