Python3 my tips lambda(ラムダ)式

Python3コード

#!/usr/bin/env python3


"""(docstring)
"""


def main():
    """(docstring)
    """

    f = lambda x, y, z: x + y + z
    print(f(1, 2, 3))
    print('')

    l1 = [(lambda x: x**1), (lambda x: x**2), (lambda x: x**3),
        (lambda x: x**4), (lambda x: x**5), (lambda x: x**6),
        (lambda x: x**7), (lambda x: x**8), (lambda x: x**9),
        (lambda x: x**10)]
    for i in l1:
        print(i(2))
    print('')

    l2 = [(lambda x, y: x**y), (lambda x, y: x**y*2), (lambda x, y: x**y*3),
        (lambda x, y: x**y*4), (lambda x, y: x**y*5), (lambda x, y: x**y*6),
        (lambda x, y: x**y*7), (lambda x, y: x**y*8), (lambda x, y: x**y*9),
        (lambda x, y: x**y*10)]
    for j in l2:
        print(j(2, 2))
    print('')

if __name__ == '__main__':
    main()

    # (乱用は避けよう。)

出力

6

2
4
8
16
32
64
128
256
512
1024

4
8
12
16
20
24
28
32
36
40