|
1 |
| -*usr_41.txt* For Vim version 9.1. Last change: 2025 Feb 01 |
| 1 | +*usr_41.txt* For Vim version 9.1. Last change: 2025 Mar 23 |
2 | 2 |
|
3 | 3 | VIM USER MANUAL - by Bram Moolenaar
|
4 | 4 |
|
@@ -839,6 +839,30 @@ List manipulation: *list-functions*
|
839 | 839 | repeat() repeat a List multiple times
|
840 | 840 | flatten() flatten a List
|
841 | 841 | flattennew() flatten a copy of a List
|
| 842 | + items() get List of List index-value pairs |
| 843 | + |
| 844 | +Tuple manipulation: *tuple-functions* |
| 845 | + copy() make a shallow copy of a Tuple |
| 846 | + count() count number of times a value appears in a |
| 847 | + Tuple |
| 848 | + deepcopy() make a full copy of a Tuple |
| 849 | + empty() check if Tuple is empty |
| 850 | + foreach() apply function to Tuple items |
| 851 | + get() get an item without error for wrong index |
| 852 | + index() index of a value in a Tuple |
| 853 | + indexof() index in a Tuple where an expression is true |
| 854 | + items() get List of Tuple index-value pairs |
| 855 | + join() join Tuple items into a String |
| 856 | + len() number of items in a Tuple |
| 857 | + list2tuple() convert a list of items into a Tuple |
| 858 | + max() maximum value in a Tuple |
| 859 | + min() minimum value in a Tuple |
| 860 | + reduce() reduce a Tuple to a value |
| 861 | + repeat() repeat a Tuple multiple times |
| 862 | + reverse() reverse the order of items in a Tuple |
| 863 | + slice() take a slice of a Tuple |
| 864 | + string() string representation of a Tuple |
| 865 | + tuple2list() convert a Tuple of items into a list |
842 | 866 |
|
843 | 867 | Dictionary manipulation: *dict-functions*
|
844 | 868 | get() get an entry without an error for a wrong key
|
@@ -1234,6 +1258,7 @@ Testing: *test-functions*
|
1234 | 1258 | test_null_list() return a null List
|
1235 | 1259 | test_null_partial() return a null Partial function
|
1236 | 1260 | test_null_string() return a null String
|
| 1261 | + test_null_tuple() return a null Tuple |
1237 | 1262 | test_settime() set the time Vim uses internally
|
1238 | 1263 | test_setmouse() set the mouse position
|
1239 | 1264 | test_feedinput() add key sequence to input buffer
|
@@ -1649,8 +1674,8 @@ More information about defining your own functions here: |user-functions|.
|
1649 | 1674 | ==============================================================================
|
1650 | 1675 | *41.8* Lists and Dictionaries
|
1651 | 1676 |
|
1652 |
| -So far we have used the basic types String and Number. Vim also supports two |
1653 |
| -composite types: List and Dictionary. |
| 1677 | +So far we have used the basic types String and Number. Vim also supports |
| 1678 | +three composite types: List, Tuple and Dictionary. |
1654 | 1679 |
|
1655 | 1680 | A List is an ordered sequence of items. The items can be any kind of value,
|
1656 | 1681 | thus you can make a List of numbers, a List of Lists and even a List of mixed
|
@@ -1751,6 +1776,23 @@ This looks into lines 1 to 50 (inclusive) and echoes any date found in there.
|
1751 | 1776 |
|
1752 | 1777 | For further reading see |Lists|.
|
1753 | 1778 |
|
| 1779 | +TUPLE |
| 1780 | + |
| 1781 | +A Tuple is an immutable ordered sequence of items. An item can be of any |
| 1782 | +type. Items can be accessed by their index number. To create a Tuple with |
| 1783 | +three strings: > |
| 1784 | +
|
| 1785 | + var atuple = ('one', 'two', 'three') |
| 1786 | +
|
| 1787 | +The Tuple items are enclosed in parenthesis and separated by commas. To |
| 1788 | +create an empty Tuple: > |
| 1789 | +
|
| 1790 | + var atuple = () |
| 1791 | +
|
| 1792 | +The |:for| loop can be used to iterate over the items in a Tuple similar to a |
| 1793 | +List. |
| 1794 | + |
| 1795 | +For further reading see |Tuples|. |
1754 | 1796 |
|
1755 | 1797 | DICTIONARIES
|
1756 | 1798 |
|
|
0 commit comments