The document contains percentage data showing that 42% of responses were for the second option, 53% were for the sixth option, and the remaining percentages were distributed among the other options with no single option receiving over 16% of responses.
3月20日にリリース予定のJDK10では12のJEPが提案され、実装/実現される見通しです。今回注目の新機能はJEP286: Local-Variable Type Inference- ローカル変数の型省略(var記法)です。このセッションではこのJEPの解説を中心に、その他主なJEPの紹介を行います。
16. 想定ユースケース
? ログ解析
? 量子化学計算などで得られたデータの処理
? →人間用のログファイルからデータを抽出、加工
? 解析例
? 以下のファイルを開いて励起エネルギーを計算
? 出力はeV単位で行う
? 抽出の時は関係ないデータを拾わないように注意
? 計算結果の例
? Molpro2012のログファイルより抜粋
!MCSCF STATE 1.1 Energy -77.591982080137
(省略)
!MCSCF STATE 2.1 Energy -77.213738400957
17. 例―MCSCFのエネルギー
import sys # 標準入力の読込準備
for l in sys.stdin(): # 標準入力を1行づつlに代入
if not ('MCSCF' in l ? # lの中にMCSCFと
and 'Energy' in l): # Energyがなければ
continue # 次の行へ
token = l.rstrip().split() # lを改行除去し空白で分割
state = token[2] # 準位は第2トークン
energy = token[4] # エネルギーは第4トークン
print(state, energy) # 準位とエネルギーを出力
19. 1. ファイルから1行づつ読み込む
? for l in sys.stdin:
? lに標準入力の内容を1行づつ代入してループ
? リダイレクト(「<」)を使うとファイルを開ける
? 読み込んだ行には改行が付いている
? l.rstrip()
? lのコピーを作ってから改行をはがして返す
? l自体の改行を削るには「l = l.rstrip()」
? 例(cat: ファイルをそのまま表示)
for l in fileinput.input(): # ファイルを1行づつ
print(l.rstrip()) # 改行削除し1行表示
20. 2. 必要な行を抽出
? if 'keyword' in l:
? keywordがlの中にあればブロックを実行する
? pythonのブロックはインデント(endifは不要)
? and, or, not
? "keyword" in lは単に条件を指示している
? →and, or, notで「かつ、または、でない」を表せる
? continue
? その外側の(for)ループから抜ける
? 例(キーワード検索)
for l in sys.stdin:
if 'Energy' in l:
print(l.rstrip())
21. 3. 必要な列を抽出
? l.rstrip().split()
? l.rstrip()はlの末尾の改行除去、.split()が分割
? 分割された文字列のリスト(配列)ができる
? リストの先頭は「0番」なので注意!
? また、リストの参照は「list[i]」で行う
? 例(1列目だけ表示)
for l in sys.stdin:
token = l.rstrip().split()
print(token[0])