Loading ...
Sorry, an error occurred while loading the content.
 

Re: Expose list index during map() execution (and a patch)

Expand Messages
  • Bram Moolenaar
    ... Looks like a good idea. ... That was a mistake, right? -- GOD: That is your purpose Arthur ... the Quest for the Holy Grail ... Monty Python and the Holy
    Message 1 of 3 , Sep 26, 2009
      Hari Krishna Dara wrote:

      > I think we can get some interesting use cases if the index of v:val is
      > exposed during the map() execution, and I think we can reuse v:key for
      > that purpose. E.g., I have a use case in which, given a list of
      > increasing numbers, get a list of differences, so something like the
      > below will get it done:
      >
      > :let l = [9, 17, 26, 36]
      > :echo map(l[1:], 'v:val-l[v:key]')
      > [8, 9, 10]
      >
      > You could achieve the above using workarounds or using a for loop, but
      > is there anything wrong in using v:key for this purpose? The change
      > seems to be minimal, as the below patch worked fine for me:

      Looks like a good idea.

      > {"tagfiles", 0, 0, f_tagfiles},
      > - {"taglist", 1, 1, f_taglist},
      > {"tempname", 0, 0, f_tempname},

      That was a mistake, right?


      --
      GOD: That is your purpose Arthur ... the Quest for the Holy Grail ...
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.