[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 2chのread.cgiへ]
Update time : 05/14 13:02 / Filesize : 255 KB / Number-of Response : 780
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

【激突】関数型言語 VS オブジェクト指向言語2



514 名前:デフォルトの名無しさん mailto:sage [2012/04/21(土) 01:27:35.30 ]
>>512
Squeak Smalltalk で。

| ui stock player |
ui := UIManager default.
stock := (1 to: 9) gather: [:each | Array new: 4 withAll: each].
stock := stock shuffled asOrderedCollection.
player := (stock removeFirst: 7) asOrderedCollection.
[ | choice |
   [ | input |
      input := ui request: player asSortedArray asString, 'から合計が15になるようにチョイス'.
      choice := input subStrings collect: #asInteger.
      choice ifEmpty: [(ui confirm: 'ギブアップ?')
         ifTrue: [^self] ifFalse: [choice := {nil}]].
      (choice allSatisfy: #isInteger)
         and: [choice sum = 15]
         and: (player includesAllOf: choice)
         and: [choice asSet allSatisfy: [:card | (player occurrencesOf: card) >= (choice occurrencesOf: card)]]
   ] whileFalse.
   player removeAll: choice.
   player addAll: (stock removeFirst: (choice size min: stock size)).
   player notEmpty] whileTrue.
ui inform: 'おめでとう!'






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<255KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef