Re: mapping list with : v:val and index of v:val

2017-06-11 Thread Nikolay Aleksandrovich Pavlov
2017-06-11 18:36 GMT+03:00 Ni Va :
> Hi,
>
> Trying this
>
>
> let file = readfile(expand("%:p"),'b')
> let g:file=map(copy(file),'v:val.":".index(copy(file), v:val)')
>
> returns -1 for each v:val of list 'file' out of 0, 1 , 2 etc..

There is `v:key`, do not use `index()` here; and using `copy()` in
`index()` is not needed. And I am unable to reproduce your problem
(vim 8.0.582), maybe need a specific set of options or specific file
contents: using file created with `writefile(range(10),
'/tmp/filename')` for the test.

Wondering whether you understand that without the context (is this
placed in a function?) `g:file` and `file` are the same variables?
(Inside a function `file` would be `l:file`.) Though based on my
knowledge of VimL this should not matter in this code: `file` will be
reassigned only after expression evaluation finishes.

>
>
> Thank you
>
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to vim_use+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mapping list with : v:val and index of v:val

2017-06-11 Thread Bram Moolenaar

Ni Va wrote:

> Trying this
> 
> 
> let file = readfile(expand("%:p"),'b')
> let g:file=map(copy(file),'v:val.":".index(copy(file), v:val)')
> 
> returns -1 for each v:val of list 'file' out of 0, 1 , 2 etc..

Works fine for me (spaces added for readability):

let file = ['aaa', 'bbb', 'ccc']
echo map(copy(file), 'v:val . ":" . index(copy(file), v:val)')

['aaa:0', 'bbb:1', 'ccc:2']


-- 
I am also told that there is a logical proof out there somewhere
that demonstrates that there is no task which duct tape cannot handle.
-- Paul Brannan

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mapping list with : v:val and index of v:val

2017-06-11 Thread Ni Va
Le dimanche 11 juin 2017 18:35:59 UTC+2, Bram Moolenaar a écrit :
> Ni Va wrote:
> 
> > Trying this
> > 
> > 
> > let file = readfile(expand("%:p"),'b')
> > let g:file=map(copy(file),'v:val.":".index(copy(file), v:val)')
> > 
> > returns -1 for each v:val of list 'file' out of 0, 1 , 2 etc..
> 
> Works fine for me (spaces added for readability):
> 
>   let file = ['aaa', 'bbb', 'ccc']
>   echo map(copy(file), 'v:val . ":" . index(copy(file), v:val)')
> 
>   ['aaa:0', 'bbb:1', 'ccc:2']
> 
> 
> -- 
> I am also told that there is a logical proof out there somewhere
> that demonstrates that there is no task which duct tape cannot handle.
>   -- Paul Brannan
> 
>  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org///
>  \\\help me help AIDS victims -- http://ICCF-Holland.org///

Reproduce it with a list made of 15 lines of a file.

But effectively I have to use v:key.
Thank you for all.

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mapping list with : v:val and index of v:val

2017-06-11 Thread Ni Va
Le dimanche 11 juin 2017 18:35:59 UTC+2, Bram Moolenaar a écrit :
> Ni Va wrote:
> 
> > Trying this
> > 
> > 
> > let file = readfile(expand("%:p"),'b')
> > let g:file=map(copy(file),'v:val.":".index(copy(file), v:val)')
> > 
> > returns -1 for each v:val of list 'file' out of 0, 1 , 2 etc..
> 
> Works fine for me (spaces added for readability):
> 
>   let file = ['aaa', 'bbb', 'ccc']
>   echo map(copy(file), 'v:val . ":" . index(copy(file), v:val)')
> 
>   ['aaa:0', 'bbb:1', 'ccc:2']
> 
> 
> -- 
> I am also told that there is a logical proof out there somewhere
> that demonstrates that there is no task which duct tape cannot handle.
>   -- Paul Brannan
> 
>  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org///
>  \\\help me help AIDS victims -- http://ICCF-Holland.org///

Reproduce it with a list made of 15 lines of a file. 

But effectively I have to use v:key. 
Thank you for all.

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mapping list with : v:val and index of v:val

2017-06-11 Thread Ni Va
Le dimanche 11 juin 2017 20:09:19 UTC+2, Ni Va a écrit :
> Le dimanche 11 juin 2017 18:35:59 UTC+2, Bram Moolenaar a écrit :
> > Ni Va wrote:
> > 
> > > Trying this
> > > 
> > > 
> > > let file = readfile(expand("%:p"),'b')
> > > let g:file=map(copy(file),'v:val.":".index(copy(file), v:val)')
> > > 
> > > returns -1 for each v:val of list 'file' out of 0, 1 , 2 etc..
> > 
> > Works fine for me (spaces added for readability):
> > 
> > let file = ['aaa', 'bbb', 'ccc']
> > echo map(copy(file), 'v:val . ":" . index(copy(file), v:val)')
> > 
> > ['aaa:0', 'bbb:1', 'ccc:2']
> > 
> > 
> > -- 
> > I am also told that there is a logical proof out there somewhere
> > that demonstrates that there is no task which duct tape cannot handle.
> > -- Paul Brannan
> > 
> >  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> > \\\  an exciting new programming language -- http://www.Zimbu.org///
> >  \\\help me help AIDS victims -- http://ICCF-Holland.org///
> 
> Reproduce it with a list made of 15 lines of a file. 
> 
> But effectively I have to use v:key. 
> Thank you for all.

Ok works fine with v:key.

let file = readfile(expand("%:p"),'b')
call map(file,'v:val.":".v:key')


nota : g:file was just to put=g:file result in my buffer to see the result.

Thank you !

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.