Search notes:

vim script: map

" ..\run_.bat map
"

redir > map.out

let s:xyz = ['foo', 'bar', 'baz']

let s:res = map(s:xyz, 'toupper(v:val)')

echo s:xyz
" ['FOO', 'BAR', 'BAZ']

echo s:res
" ['FOO', 'BAR', 'BAZ']

fu! Double(n) " {
  return a:n . '-' . a:n
endfu " }

let s:funcRef = function('Double')

call map(s:xyz, string(s:funcRef) . '(v:val)')
" ['FOO-FOO', 'BAR-BAR', 'BAZ-BAZ']

echo s:xyz

"
"  Using lambda expressions
"
if has('lambda')
   call map(s:xyz, {pos,val -> pos . ': ' . tolower(val)})
   echo s:xyz
 " ['0: foo-foo', '1: bar-bar', '2: baz-baz']
else
   echo 'feature lambda not available'
endif

redir END
q
Github repository about-vim, path: /vimscript/functions/map.vim

See also

Vim: built in functions
Common first class function: map
VIM script

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758184259, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/vim/script/vimscript/functions/map(82): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78