2010-01-26から1日間の記事一覧

文字の出現頻度を調べる

1つの文字列に特定の文字の出現頻度を調べます。 例として、円周率における出現頻度を扱います def char_stat(str){ table = [:] m = (~/(?m)./).matcher(str) m.find() m.each { word -> table[word] = table.get(word,0) + 1 } list = table.keySet().toLi…