Letter frequency: Difference between revisions

→‎{{header|Julia}}: More compact and idiomatic code
m (→‎{{header|Perl 6}}: style twiddles)
(→‎{{header|Julia}}: More compact and idiomatic code)
Line 1,539:
 
<lang julia>using DataStructures
 
function letterfreq(file::AbstractString; fltr::Function=(_) -> true)
h = sort(Dict(counter(Charfilter(fltr, readstring(file)))))
for c in readstring(file)
push!(h, c)
end
h = Dict(h)
filter!((k, _) -> fltr(k), h)
return sort(h)
end