> function! WordFrequency1() range
>   let a=[]
>   let b={}
>   let a=split(join(getline(a:firstline,a:lastline)),'\A\+')
>   for word in a
>     let b[word]=(exists("b[word]")?b[word]+1:1

This can be more clea[rn]ly written as

   let b[word]=get(b, word, 0) + 1

which gets "b[word]" if it exists, or defaults to 0 if it 
doesn't.  (It's a retweaking of a Python idiom "b.get(word,0)" as 
a lot of the list/dict stuff in Vim seems to be influenced by 
Python's syntax)

-tim



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to