I have the word describe
, and I want to see how many times each letter appears in the word. Eg \"e\" appears twice, \"d\" appears once etc
I have tried
You can use frequencies to count the frequency at which each character appears in the string, returning a map like this:
(frequencies "ababacdefg")
=> {\a 3, \b 2, \c 1, \d 1, \e 1, \f 1, \g 1}
This works because the string is being treated as a sequence of characters. frequencies
can be used on general collections:
(frequencies [1 1 2 3])
=> {1 2, 2 1, 3 1}
The key is the value being counted, and the value is the frequency.