On 23/12/09 13:04, epanda wrote:
Hi,

I am building some info in Dict and hash like this :
------------------------------------
let myHash = {}

let g:cnt = 1
g/pattern/=call storingData()/



func! storingData(param1, param2)

   let myHash[g:cnt] = {'information':a:param1  , 'clue':a:param2 }

   let g:cnt += 1
endfunc
-------------------------

I would like to know if I can map only the field of a dictionnary: eg
information below
Furthermore, I would like to map differently my two fields
"information" and "clue"

Can we do that ?
map(copy(values(myHash).information,"PREFIX_BARTEXT v:val
SUFFIX_BARTEXT")
map(copy(values(myHash).clue," v:val SUFFIX_FOOTEXT")


Thanks


Well, what about

:let copyHash = map(copy(myHash), 'v:key == "information"? (PREFIX_BARTEXT . " " . v:val . " " . SUFFIX_BARTEXT) : v:key == "clue"? (v:val . " " . SUFFIX_FOOTEXT) : v:val'

? This assumes that PREFIX_BARTEXT, SUFFIX_BARTEXT and SUFFIX_FOOTEXT are variables. If they are string literals, push them into the quotes containing the space between them and v:val of course. I think that the parentheses are not really necessary but that they make it easier to read.


Best regards,
Tony.
--
A total abstainer is one who abstains from everything but abstention,
and especially from inactivity in the affairs of others.
                -- Ambrose Bierce, "The Devil's Dictionary"

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

Reply via email to