码迷,mamicode.com
首页 > 其他好文 > 详细

函数式编程

时间:2018-03-29 22:36:11      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:none   foo   one   函数   class   turn   函数式编程   输出   rom   

编程的三种方法论:

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()

函数式编程

标签:none   foo   one   函数   class   turn   函数式编程   输出   rom   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!