diff --git a/doc/usr_41.jax b/doc/usr_41.jax index 6d8a69b39..b457b7dfc 100644 --- a/doc/usr_41.jax +++ b/doc/usr_41.jax @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim バージョン 9.1. Last change: 2025 Feb 01 +*usr_41.txt* For Vim バージョン 9.1. Last change: 2025 Mar 23 VIM USER MANUAL - by Bram Moolenaar @@ -812,6 +812,32 @@ substitute() の呼び出しの前後にいろいろな処理を入れたりす repeat() リストを複数回繰り返す flatten() リストの平坦化 flattennew() リストのコピーを平坦化 + items() リストのインデックスと値のペアのリストを取得す + る + +Tuple 操作: *tuple-functions* + copy() Tuple の浅いコピーを作成する + count() Tuple 内で値が出現する回数を返す + deepcopy() Tuple の完全なコピーを作成する + empty() Tuple が空であるか判定する + foreach() Tuple の項目に関数を適用する + get() Tuple の項目を取得。間違ったインデックスでもエ + ラーにならない + index() Tuple 内の値のインデックス + indexof() Tuple で式の評価が真となった位置のインデックス + items() Tuple のインデックスと値のペアのリストを取得す + る + join() Tuple の項目を連結し、文字列にする + len() Tuple 中の項目の個数 + list2tuple() 項目のリストを Tuple に変換する + max() Tuple 中の最大値 + min() Tuple 中の最小値 + reduce() Tuple を値に縮める + repeat() Tuple を複数回繰り返す + reverse() Tuple 内の項目の並び順を反転させる + slice() Tuple のスライスを取る + string() Tuple の文字列表現 + tuple2list() Tuple の項目をリストに変換する 辞書操作: *dict-functions* get() 辞書の要素を返す。存在しないキーでもエラーを出 @@ -1207,6 +1233,7 @@ Vimサーバー: *server-functions* test_null_list() null のリストを返す test_null_partial() null の部分適用を返す test_null_string() null の文字列を返す + test_null_tuple() null の Tuple を返す test_settime() Vimが内部的に用いる時間を設定する test_setmouse() マウスの位置を設定する test_feedinput() インプットバッファにキーシーケンスを追加する @@ -1623,8 +1650,8 @@ Note 関数への参照を保持する変数の名前は大文字で始めなけ ============================================================================== *41.8* リストと辞書 -ここまでは基本型(文字列と数値)を扱ってきました。Vim は二つの複合型、リストと辞 -書もサポートしています。 +ここまでは基本型(文字列と数値)を扱ってきました。Vim は 3 つの複合型、リスト、 +Tuple と辞書もサポートしています。 リストとは、要素を順番に並べたものです。要素はどのような型でも構いません。数値 のリスト、リストのリスト、あるいは複数の型が混在したリストでも作れます。例え @@ -1725,6 +1752,23 @@ range()が生成するリストの最初の要素は0であることに注意し さらなる情報については |Lists| を参照してください。 +TUPLE + +Tuple は、不変の順序付きの項目のシーケンスです。項目は任意の型にすることができ +ます。項目にはインデックス番号でアクセスできます。3 つの文字列を含む Tuple を +作成するには、次のようにします: > + + var atuple = ('one', 'two', 'three') + +Tuple 項目は括弧で囲まれ、コンマで区切られます。空の Tuple を作成するには: > + + var atuple = () + +|:for| ループは、リストと同様に Tuple 内の項目を反復処理するために使用できま +す。 + +詳細については、|Tuples| を参照してください。 + ☆辞書 辞書はキーと値のペアを保持します。キーを指定することで高速に値を検索できます。 diff --git a/en/usr_41.txt b/en/usr_41.txt index 0d09fc9c5..4c5e5ef4c 100644 --- a/en/usr_41.txt +++ b/en/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 9.1. Last change: 2025 Feb 01 +*usr_41.txt* For Vim version 9.1. Last change: 2025 Mar 23 VIM USER MANUAL - by Bram Moolenaar @@ -839,6 +839,30 @@ List manipulation: *list-functions* repeat() repeat a List multiple times flatten() flatten a List flattennew() flatten a copy of a List + items() get List of List index-value pairs + +Tuple manipulation: *tuple-functions* + copy() make a shallow copy of a Tuple + count() count number of times a value appears in a + Tuple + deepcopy() make a full copy of a Tuple + empty() check if Tuple is empty + foreach() apply function to Tuple items + get() get an item without error for wrong index + index() index of a value in a Tuple + indexof() index in a Tuple where an expression is true + items() get List of Tuple index-value pairs + join() join Tuple items into a String + len() number of items in a Tuple + list2tuple() convert a list of items into a Tuple + max() maximum value in a Tuple + min() minimum value in a Tuple + reduce() reduce a Tuple to a value + repeat() repeat a Tuple multiple times + reverse() reverse the order of items in a Tuple + slice() take a slice of a Tuple + string() string representation of a Tuple + tuple2list() convert a Tuple of items into a list Dictionary manipulation: *dict-functions* get() get an entry without an error for a wrong key @@ -1234,6 +1258,7 @@ Testing: *test-functions* test_null_list() return a null List test_null_partial() return a null Partial function test_null_string() return a null String + test_null_tuple() return a null Tuple test_settime() set the time Vim uses internally test_setmouse() set the mouse position test_feedinput() add key sequence to input buffer @@ -1649,8 +1674,8 @@ More information about defining your own functions here: |user-functions|. ============================================================================== *41.8* Lists and Dictionaries -So far we have used the basic types String and Number. Vim also supports two -composite types: List and Dictionary. +So far we have used the basic types String and Number. Vim also supports +three composite types: List, Tuple and Dictionary. A List is an ordered sequence of items. The items can be any kind of value, 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. For further reading see |Lists|. +TUPLE + +A Tuple is an immutable ordered sequence of items. An item can be of any +type. Items can be accessed by their index number. To create a Tuple with +three strings: > + + var atuple = ('one', 'two', 'three') + +The Tuple items are enclosed in parenthesis and separated by commas. To +create an empty Tuple: > + + var atuple = () + +The |:for| loop can be used to iterate over the items in a Tuple similar to a +List. + +For further reading see |Tuples|. DICTIONARIES