diff --git a/doc/reference/reference_lua/table.rst b/doc/reference/reference_lua/table.rst index 9083f0987a..e6f0791de3 100644 --- a/doc/reference/reference_lua/table.rst +++ b/doc/reference/reference_lua/table.rst @@ -1,36 +1,37 @@ -.. _table-module: +.. _table-module: ------------------------------------------------------------------------------- Module table ------------------------------------------------------------------------------- -.. module:: table +.. module:: table The :code:`table` module has everything in the `standard Lua table library `_, and some Tarantool extensions. -You can see this by saying "table": you will see this list of functions: -``clear`` (LuaJIT extension = erase all elements), -`concat `_ (concatenate), -``copy`` (make a copy of an array), -``deepcopy`` (see description below), -``foreach``, -``foreachi``, -`getn `_ (get the number of elements in an array), -`insert `_ (insert an element into an array), -`maxn `_ (get largest index) -`move `_ (move elements between tables), -``new`` (LuaJIT extension = return a new table with pre-allocated elements), -`remove `_ (remove an element from an array), -`sort `_ (sort the elements of an array). +Write ``table`` to see the list of functions: + +* ``clear`` (LuaJIT extension = erase all elements) +* `concat `_ (concatenate) +* ``copy`` (make a copy of an array) +* ``deepcopy`` (see the :ref:`description ` below) +* ``foreach`` +* ``foreachi`` +* `getn `_ (get the number of elements in an array) +* `insert `_ (insert an element into an array) +* `maxn `_ (get the largest index) +* `move `_ (move elements between tables) +* ``new`` (LuaJIT extension = return a new table with pre-allocated elements) +* `remove `_ (remove an element from an array) +* `sort `_ (sort the elements of an array) In this section we only discuss the additional function that the Tarantool developers have added: ``deepcopy``. -.. _table-deepcopy: +.. _table-deepcopy: -.. function:: deepcopy(input-table) +.. function:: deepcopy(input-table) Return a "deep" copy of the table -- a copy which follows nested structures to any depth and does not depend on pointers, @@ -60,29 +61,29 @@ that the Tarantool developers have added: ``deepcopy``. - b ... -.. _table-sort: +.. _table-sort: -.. function:: sort(input-table [, comparison-function]) +.. function:: sort(input-table [, comparison-function]) Put the input-table contents in sorted order. The `basic Lua table.sort `_ - has a default comparison-function: :code:`function (a, b) return a < b end`. + has a default comparison function: :code:`function (a, b) return a < b end`. That is efficient and standard. However, sometimes Tarantool users will want an equivalent to ``table.sort`` which has any of these features: - (1) If the table contains nils, except nils at the end, the results must still be correct. - That is not the case with the default tarantool_sort, and it cannot - be fixed by making a comparison that checks whether a and b are nil. - (Before trying certain Internet suggestions, test with - {1, nil, 2, -1, 44, 1e308, nil, 2, nil, nil, 0}. + #. If the table contains nils, except nils at the end, the results must still be correct. + That is not the case with the default ``tarantool_sort``, and it cannot + be fixed by making a comparison that checks whether ``a`` and ``b`` are ``nil``. + (Before trying certain Internet suggestions, test with + :code:`{1, nil, 2, -1, 44, 1e308, nil, 2, nil, nil, 0}`. - (2) If strings are to be sorted in a language-aware way, there must be a - parameter for collation. + #. If strings are to be sorted in a language-aware way, there must be a + parameter for collation. - (3) If the table has a mix of types, then they must be sorted as - booleans, then numbers, then strings, then byte arrays. + #. If the table has a mix of types, then they must be sorted as + booleans, then numbers, then strings, then byte arrays. Since all those features are available in Tarantool spaces, the solution for Tarantool is simple: make a temporary Tarantool @@ -94,7 +95,9 @@ that the Tarantool developers have added: ``deepcopy``. it requires a database privilege, so it should only be used if the extra features are necessary. - .. code-block:: none + **Example:** + + .. code-block:: lua function tarantool_sort(input_table, collation) local c = collation or 'binary' @@ -118,5 +121,7 @@ that the Tarantool developers have added: ``deepcopy``. box.space[tmp_name]:drop() end - For example, suppose table t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}. - After tarantool_sort(t, 'unicode_ci') t contains {nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}. + + For example, suppose :code:`table t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}`. + + After ``tarantool_sort(t, 'unicode_ci')`` ``t`` contains :code:`{nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}`. diff --git a/locale/ru/LC_MESSAGES/reference/reference_lua/table.po b/locale/ru/LC_MESSAGES/reference/reference_lua/table.po index f8d10300e3..508bdd28fb 100644 --- a/locale/ru/LC_MESSAGES/reference/reference_lua/table.po +++ b/locale/ru/LC_MESSAGES/reference/reference_lua/table.po @@ -11,39 +11,35 @@ msgstr "" "некоторые расширения специально для Tarantool." msgid "" -"You can see this by saying \"table\": you will see this list of functions: " -"``clear`` (LuaJIT extension = erase all elements), `concat " -"`_ " -"(concatenate), ``copy`` (make a copy of an array), ``deepcopy`` (see " -"description below), ``foreach``, ``foreachi``, `getn " -"`_ (get the number of elements in an " -"array), `insert `_ (insert an element into an array), `maxn " -"`_ (get largest " -"index) `move `_ " -"(move elements between tables), ``new`` (LuaJIT extension = return a new " -"table with pre-allocated elements), `remove " -"`_ (remove an " -"element from an array), `sort " -"`_ (sort the " -"elements of an array)." +"Write ``table`` to see the list of functions: " +"``clear`` (LuaJIT extension = erase all elements)" +"`concat `_ (concatenate)" +"``copy`` (make a copy of an array)" +"``deepcopy`` (see the :ref:`description ` below)" +"``foreach``" +"``foreachi``" +"`getn `_ (get the number of elements in an array)" +"`insert `_ (insert an element into an array)" +"`maxn `_ (get еру largest index)" +"`move `_ (move elements between tables)" +"``new`` (LuaJIT extension = return a new table with pre-allocated elements)" +"`remove `_ (remove an element from an array) +"`sort `_ (sort the elements of an array)" msgstr "" -"Чтобы убедиться в этом, выполните команду \"table\": вы увидите список " -"функций: ``clear`` (расширение LuaJIT = удаление всех элементов), `concat " -"`_ " -"(конкатенация), ``copy`` (создание копии массива), ``deepcopy`` (см. " -"описание ниже), ``foreach``, ``foreachi``, `getn " -"`_ (получение количества элементов в " -"массиве), `insert `_ (вставка элемента в массив), `maxn " -"`_ (получение " -"самого большого индекса) `move " -"`_ (перемещение " -"элементов между таблицами), ``new`` (расширение LuaJIT = возврат новой " -"таблицы с предварительно выделенными элементами), `remove " -"`_ (удаление " -"элемента из массива), `sort `_ (сортировка элементов массива)." +"Чтобы убедиться в этом, выполните команду \"table\": вы увидите список функций: " +"``clear`` (расширение LuaJIT = удаление всех элементов)," +"`concat `_ (конкатенация)," +"``copy`` (создание копии массива)," +"``deepcopy`` (см. :ref:`описание ` ниже)," +"``foreach``," +"``foreachi``," +"`getn `_ (получение количества элементов в массиве)," +"`insert `_ (вставка элемента в массив)," +"`maxn `_ (получение самого большого индекса)," +"`move `_ (перемещение элементов между таблицами)," +"``new`` (расширение LuaJIT = возврат новой таблицы с предварительно выделенными элементами)," +"`remove `_ (удаление элемента из массива)," +"`sort `_ (сортировка элементов массива)." msgid "" "In this section we only discuss the additional function that the Tarantool " @@ -117,7 +113,7 @@ msgstr "Размещение содержимого введенной табл msgid "" "The `basic Lua table.sort `_ has a default comparison-function: :code:`function (a, b) " +"table.sort>`_ has a default comparison function: :code:`function (a, b) " "return a < b end`." msgstr "" "В базовой сортировке в Lua, `table.sort " @@ -133,31 +129,31 @@ msgstr "" "может понадобиться эквивалент ``table.sort`` со следующими функциями:" msgid "" -"(1) If the table contains nils, except nils at the end, the results must " -"still be correct. That is not the case with the default tarantool_sort, and " -"it cannot be fixed by making a comparison that checks whether a and b are " -"nil. (Before trying certain Internet suggestions, test with {1, nil, 2, -1, " -"44, 1e308, nil, 2, nil, nil, 0}." +"#. If the table contains nils, except nils at the end, the results must " +"still be correct. That is not the case with the default ``tarantool_sort``, and " +"it cannot be fixed by making a comparison that checks whether ``a`` and ``b`` are " +"``nil``. (Before trying certain Internet suggestions, test with :code:`{1, nil, 2, -1, " +"44, 1e308, nil, 2, nil, nil, 0}`." msgstr "" -"(1) Если таблица содержит нулевые значения, за исключением нулей в конце, " +"#. Если таблица содержит нулевые значения, за исключением нулей в конце, " "результаты все равно должны быть правильными. Это не работает при " -"использовании стандартного tarantool_sort, и это нельзя исправить, выполнив " -"сравнение, которое проверяет, равны ли значения a и b нулю. (Прежде чем " -"пробовать определенные предложения в Интернете, проверьте {1, nil, 2, -1, " -"44, 1e308, nil, 2, nil, nil, 0}." +"использовании стандартного ``tarantool_sort``, и это нельзя исправить, выполнив " +"сравнение, которое проверяет, равны ли значения ``a`` и ``b`` нулю. (Прежде чем " +"пробовать определенные предложения в Интернете, проверьте ``{1, nil, 2, -1, " +"44, 1e308, nil, 2, nil, nil, 0}``." msgid "" -"(2) If strings are to be sorted in a language-aware way, there must be a " +"#. If strings are to be sorted in a language-aware way, there must be a " "parameter for collation." msgstr "" -"(2) Если строки должны быть отсортированы с учетом языка, должен быть " +"#. Если строки должны быть отсортированы с учетом языка, должен быть " "параметр для сравнения символов." msgid "" -"(3) If the table has a mix of types, then they must be sorted as booleans, " +"#. If the table has a mix of types, then they must be sorted as booleans, " "then numbers, then strings, then byte arrays." msgstr "" -"(3) Если в таблица есть разные типы, то они должны быть отсортированы так: " +"#. Если в таблица есть разные типы, то они должны быть отсортированы так: " "логические, затем числа, затем строки, а затем байтовые массивы." msgid "" @@ -204,8 +200,8 @@ msgid "" " box.space[tmp_name]:drop()\n" " end\n" "\n" -"For example, suppose table t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}.\n" -"After tarantool_sort(t, 'unicode_ci') t contains {nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}." +"For example, suppose :code:`table t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}`.\n" +"After ``tarantool_sort(t, 'unicode_ci')`` ``t`` contains :code:`{nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}`." msgstr "" "function tarantool_sort(input_table, collation)\n" " local c = collation or 'binary'\n" @@ -229,5 +225,5 @@ msgstr "" " box.space[tmp_name]:drop()\n" " end\n" "\n" -"Например, предположим, что таблица t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}.\n" -"После tarantool_sort(t, 'unicode_ci') t содержит {nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}." +"Например, предположим, что таблица ``t = {1, 'A', -88.3, nil, true, 'b', 'B', nil, 'À'}``.\n" +"После ``tarantool_sort(t, 'unicode_ci')`` ``t`` содержит ``{nil, nil, true, -88.3, 1, 'A', 'À', 'b', 'B'}``."