Letter frequency: Difference between revisions

add julia example
(→‎TXR Lisp: More concise.)
(add julia example)
Line 966:
return freqs;
}</lang>
 
=={{header|Julia}}==
This will return the frequency of all characters in file, including newlines. Filter the result according to the desired set of letters.
<lang Julia>
function freq(file)
h = Dict{Char, Integer}()
for x in open(readchomp,file) h[x] = get(h,x,0)+1 end
sort(collect(h))
end</lang>
{{Out}}
<pre>julia> filter(l-> l[1] in ['a':'z','A':'Z'] , freq("somefile.txt"))
52-element Array{(Char,Integer),1}:
('A',478)
('B',453)
...
</pre>
 
=={{header|K}}==