思想,最好用哪种函数式编程语言入门
1个回答
展开全部
lisp/coljurepython也可以<pre t="code" l="python">>>> g = lambda x: x * 2
>>> g(3)
6
>>> (lambda x: x * 2)(3)
6
<pre t="code" l="python">>>> def f(x): return x % 2 != 0 and x % 3 != 0
>>> filter(f, range(2, 25))
[5, 7, 11, 13, 17, 19, 23]
>>> def f(x): return x != 'a'
>>> filter(f, "abcdef")
'bcdef'
<pre t="code" l="python">>>> def cube(x): return x*x*x
>>> map(cube, range(1, 11))
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
>>> def cube(x) : return x + x
>>> map(cube , "abcde")
['aa', 'bb', 'cc', 'dd', 'ee']
>>> g(3)
6
>>> (lambda x: x * 2)(3)
6
<pre t="code" l="python">>>> def f(x): return x % 2 != 0 and x % 3 != 0
>>> filter(f, range(2, 25))
[5, 7, 11, 13, 17, 19, 23]
>>> def f(x): return x != 'a'
>>> filter(f, "abcdef")
'bcdef'
<pre t="code" l="python">>>> def cube(x): return x*x*x
>>> map(cube, range(1, 11))
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
>>> def cube(x) : return x + x
>>> map(cube , "abcde")
['aa', 'bb', 'cc', 'dd', 'ee']
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询