Differences between revisions 1 and 2
Revision 1 as of 2018-10-28 15:29:16
Size: 285
Comment:
Revision 2 as of 2018-10-29 04:56:11
Size: 631
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
===== =====
===== λ式 =====
Line 11: Line 12:
  *   * λ式を使うと下記のように,簡潔に書けますが,必ずしも,読みやすいとは言えません.

{{{#!highlight python numbers=off
import random

# 乱数で「じゃんけんの手」を求める関数 (0,1,2の整数で返す)
janken_random_hand = lambda: random.randint( 0, 2 )

janken_random_hand()
}}}

λ式
  • 【高度な話題】
    • λ式を使うと下記のように,簡潔に書けますが,必ずしも,読みやすいとは言えません.

import random

# 乱数で「じゃんけんの手」を求める関数 (0,1,2の整数で返す)
janken_random_hand = lambda: random.randint( 0, 2 )

janken_random_hand()

SoftEng: Python/Prog/Practice/Extended/02/EP_002a/AdvancedTopics (last edited 2018-10-29 05:03:02 by TadashiIijima)