Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Frequency Count of Unique Symbols
- " Barry Arthur, 2012 01 09
- function! Symbols()
- let lines = join(getline(1,'$'))
- let lines = substitute(lines, '"\w.\{-}"', '', 'g')
- return sort(filter(split(lines, '\s\+\|[-|''"=+$#@!.,{}()\[\]]'), 'v:val != ""'))
- endfunction
- function! DictSort(i1, i2)
- return a:i1[1] == a:i2[1] ? 0 : a:i1[1] > a:i2[1] ? 1 : -1
- endfunction
- function! Unique(symbols)
- let sym = {}
- for s in a:symbols
- if has_key(sym, s)
- let sym[s] += 1
- else
- let sym[s] = 1
- end
- endfor
- return sort(items(sym), 'DictSort')
- endfunction
- function! PrettyPrint(data)
- for r in a:data
- echo r
- endfor
- endfunction
- call PrettyPrint(Unique(Symbols()))
Advertisement
Add Comment
Please, Sign In to add comment