【激突】関数型言語 VS オブジェクト指向言語2at TECH【激突】関数型言語 VS オブジェクト指向言語2 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト513:デフォルトの名無しさん 12/04/20 23:16:37.51 つまらない。 514:デフォルトの名無しさん 12/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: 'おめでとう!' 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch