[過去ログ]
プログラミングのお題スレ Part13 (1002レス)
プログラミングのお題スレ Part13 http://mevius.5ch.net/test/read.cgi/tech/1549160513/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
745: デフォルトの名無しさん [sage] 2019/03/21(木) 11:30:55.91 ID:4Lv8Ku6J >>494 Squeak Smalltalk。コンマを分割と見なしそれぞれについての和を出力させてみた | fn | fn := [:columnName | FileStream oldFileNamed: 'data.txt' do: [:file | | index sum | index := (file nextLine subStrings: ' ') indexOf: columnName. sum := 0. [file atEnd] whileFalse: [ | next | next := ((file nextLine subStrings: ' ') at: index) subStrings: ','. sum := sum + (next size = 1 ifTrue: [next anyOne] ifFalse: [next])]. sum ] ]. fn value: 'カラム3'. "=> 7.1 " fn value: 'カラム1'. "=> #(3.1 2.1) " http://mevius.5ch.net/test/read.cgi/tech/1549160513/745
748: デフォルトの名無しさん [sage] 2019/03/21(木) 22:33:42.92 ID:4Lv8Ku6J >>723 Squeak Smalltalk | fn | fn := [:int1 :int2 | | strings width digits interms ans max line | strings := {int1. int2} collect: #asString. width := (strings detectMax: #size) size. digits := strings collect: [:str | (str forceTo: width paddingStartWith: $0) reversed asArray collect: #asString]. interms := (digits reduce: #+) collectWithIndex: [:interm :idx | interm, (String new: idx-1 withAll: Character space)]. ans := interms polynomialEval: '10'. strings atLast: 1 put: '+ ', strings last. max := ((strings, {ans}) collect: #size) max. line := String new: max withAll: $-. (strings, {line}, interms, {line. ans} collect: [:str | (str forceTo: max paddingStartWith: Character space) withoutTrailingBlanks ]) asStringWithCr ]. fn value: 987 value: 65. "=> ' 987 + 65 ---- 12 14 9 ---- 1052' " http://mevius.5ch.net/test/read.cgi/tech/1549160513/748
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.032s