Letter frequency: Difference between revisions

Content added Content deleted
(Add Refal)
 
Line 4,727: Line 4,727:


=={{header|langur}}==
=={{header|langur}}==
<syntaxhighlight lang="langur">val .countLetters = fn(.s) {
<syntaxhighlight lang="langur">
val countLetters = fn(s) {
for[=h{}] .s2 in split(replace(.s, RE/\P{L}/)) {
for[={:}] s2 in split(replace(s, RE/\P{L}/)) {
_for[.s2; 0] += 1
_for[s2; 0] += 1
}
}
}
}


val .counts = .countLetters(readfile "./fuzz.txt")
val counts = countLetters(readfile("./fuzz.txt"))
writeln join "\n", map fn(.k) $"\.k;: \.counts[.k];", keys .counts
writeln join("\n", map(fn(k) { "{{k}}: {{counts[k]}}" }, keys(counts)))
</syntaxhighlight>
</syntaxhighlight>