On 12/10/2011 01:52 p.m., Christian Brabandt wrote: > Hi niva! > > On Mi, 12 Okt 2011, niva wrote: > >> Hi >> >> I have some data organized by column in a buffer like that : >> >> >> ; ; ; 48.00 ; >> ; ; ; 32.50 ; >> ; ; ; 15.00 ; >> ; ; ; 59.40 ; >> ; 47.80 ; ; ; >> ; 10.90 ; ; ; >> >> >> ; 12.38 ; ; ; >> >> ; ; ; 35.65 ; >> ; 10.90 ; ; ; >> ; 29.99 ; ; ; >> ; ; ; 342.57 ; >> ; ; ; 400.00 ; >> >> I would like to got the most faster method that sum each column like >> done in Excel by SUM() function. > > fu! Sum(col) > let fields=map(getline(1,'$'), 'split(v:val, ";")[a:col]') > call filter(fields, 'str2nr(v:val)') > return eval(join(fields, '+')) > endfu > > com -nargs=1 Sum :call Sum(<args>)
If I apply your function to the above example, say Sum 3 I get: Error detected while processing function Sum: line 1: E684: list index out of range: 3 Regards, -- Cesar -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
