File: lambda_module_T603.pyx

package info (click to toggle)
cython 0.21.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,804 kB
  • ctags: 31,405
  • sloc: python: 55,862; ansic: 8,318; xml: 1,031; cpp: 777; makefile: 383; lisp: 206; sh: 7
file content (30 lines) | stat: -rw-r--r-- 440 bytes parent folder | download | duplicates (10)
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: 603

# 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