函数式编程

编程的三种方法论:

1面向过程

2函数式

3面向对象

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

高阶函数:1,把函数当做参数传给另一个函数。2回值当中包含函数。。两者满足一种就是高阶函数


#把函数当做参数传给另一个函数
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值