summaryrefslogtreecommitdiff
path: root/tests/run/lambda_module_T603.pyx
blob: c92fce5df238dbdbdc564d41e2cb603a7f26e906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# mode: run
# tag: lambda
# ticket: t603

# Module scope lambda functions

__doc__ = """
>>> pow2(16)
256
>>> with_closure(0)
0
>>> typed_lambda(1)(2)
3
>>> typed_lambda(1.5)(1.5)
2
>>> cdef_const_lambda()
123
>>> const_lambda()
321
"""

pow2 = lambda x: x * x
with_closure = lambda x:(lambda: x)()
typed_lambda = lambda int x : (lambda int y: x + y)

cdef int xxx = 123
cdef_const_lambda = lambda: xxx

yyy = 321
const_lambda = lambda: yyy