Search notes:

vim script: array operations

"
"  ..\run_ array_operations

redir > array_operations.out

let a = ['one', 'two', 'three']

echo a[0]
" one

echo a[1:]
" ['two', 'three']

echo a[:1]
" ['one', 'two']

call add(a, 'four')
echo a
" ['one', 'two', 'three', 'four']

call extend(a, ['five', 'six', 'seven'])
echo a
" ['one', 'two', 'three', 'four', 'five', 'six', 'seven']

call extend(a, ['***', '###'], 4)
echo a
" ['one', 'two', 'three', 'four', '***', '###', 'five', 'six', 'seven']

let r = remove(a, -1)
echo r
" seven

echo a
" ['one', 'two', 'three', 'four', '***', '###', 'five', 'six']

let p = remove(a, 4, 5)
echo p
" ['***', '###']

echo a
" ['one', 'two', 'three', 'four', 'five', 'six']

let b = a + ['using', 'plus']
echo b
" ['one', 'two', 'three', 'four', 'five', 'six', 'using', 'plus']

echo 'len(b): ' . len(b)
" len(b): 8

q
Github repository about-vim, path: /vimscript/arrays-and-hashes/array_operations.vim

See also

array and hashes
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...', 1759561892, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/vim/script/vimscript/arrays-and-hashes/array_operations(90): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78