diff --git a/library/itertools.po b/library/itertools.po index 111c072e5b..e6f6d956c8 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-06-02 00:03+0000\n" -"PO-Revision-Date: 2018-05-23 16:04+0000\n" +"PO-Revision-Date: 2024-07-09 13:34+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -17,6 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.4.4\n" #: ../../library/itertools.rst:2 msgid "" @@ -29,6 +30,9 @@ msgid "" "by constructs from APL, Haskell, and SML. Each has been recast in a form " "suitable for Python." msgstr "" +"這個模組實作了許多 :term:`疊代器 (iterator) ` 構建塊 (building " +"block),其靈感來自 APL、Haskell 和 SML 的結構。每個構建塊都以適合 Python 的形" +"式來重新設計。" #: ../../library/itertools.rst:24 msgid "" @@ -37,6 +41,9 @@ msgid "" "algebra\" making it possible to construct specialized tools succinctly and " "efficiently in pure Python." msgstr "" +"這個模組標準化了快速且高效率利用記憶體的核心工具集,這些工具本身或組合使用都" +"很有用。它們共同構成了一個「疊代器代數 (iterator algebra)」,使得在純 " +"Python 中簡潔且高效地建構專用工具成為可能。" #: ../../library/itertools.rst:29 msgid "" @@ -44,6 +51,9 @@ msgid "" "a sequence ``f(0), f(1), ...``. The same effect can be achieved in Python " "by combining :func:`map` and :func:`count` to form ``map(f, count())``." msgstr "" +"例如,SML 提供了一個造表工具:``tabulate(f)``,它產生一個序列 ``f(0), " +"f(1), ...``。在 Python 中,可以透過結合 :func:`map` 和 :func:`count` 組成 " +"``map(f, count())`` 以達到同樣的效果。" #: ../../library/itertools.rst:33 msgid "" @@ -53,15 +63,18 @@ msgid "" "efficient dot-product: ``sum(starmap(operator.mul, zip(vec1, vec2, " "strict=True)))``." msgstr "" +"這些工具及其內建的對等部分 (counterpart) 也可以很好地與 :mod:`operator` 模組" +"中的高速函式配合使用。例如,乘法運算子可以對映到兩個向量上以組成高效率的內" +"積:``sum(starmap(operator.mul, zip(vec1, vec2, strict=True)))``。" #: ../../library/itertools.rst:39 msgid "**Infinite iterators:**" -msgstr "" +msgstr "**無限疊代器:**" #: ../../library/itertools.rst:42 ../../library/itertools.rst:52 #: ../../library/itertools.rst:73 msgid "Iterator" -msgstr "" +msgstr "疊代器" #: ../../library/itertools.rst:42 ../../library/itertools.rst:52 #: ../../library/itertools.rst:73 @@ -119,7 +132,7 @@ msgstr "elem [,n]" #: ../../library/itertools.rst:46 msgid "elem, elem, elem, ... endlessly or up to n times" -msgstr "" +msgstr "elem, elem, elem,... 重複無限次或 n 次" #: ../../library/itertools.rst:46 msgid "``repeat(10, 3) → 10 10 10``" @@ -127,7 +140,7 @@ msgstr "``repeat(10, 3) → 10 10 10``" #: ../../library/itertools.rst:49 msgid "**Iterators terminating on the shortest input sequence:**" -msgstr "" +msgstr "**在最短輸入序列 (shortest input sequence) 處終止的疊代器:**" #: ../../library/itertools.rst:54 msgid ":func:`accumulate`" @@ -183,7 +196,7 @@ msgstr ":func:`chain.from_iterable`" #: ../../library/itertools.rst:57 ../../library/itertools.rst:63 msgid "iterable" -msgstr "" +msgstr "可疊代物件" #: ../../library/itertools.rst:57 msgid "``chain.from_iterable(['ABC', 'DEF']) → A B C D E F``" @@ -195,7 +208,7 @@ msgstr ":func:`compress`" #: ../../library/itertools.rst:58 msgid "data, selectors" -msgstr "" +msgstr "data, selectors" #: ../../library/itertools.rst:58 msgid "(d[0] if s[0]), (d[1] if s[1]), ..." @@ -216,7 +229,7 @@ msgstr "predicate, seq" #: ../../library/itertools.rst:59 msgid "seq[n], seq[n+1], starting when predicate fails" -msgstr "" +msgstr "seq[n], seq[n+1],當 predicate 失敗時開始" #: ../../library/itertools.rst:59 msgid "``dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8``" @@ -228,7 +241,7 @@ msgstr ":func:`filterfalse`" #: ../../library/itertools.rst:60 msgid "elements of seq where predicate(elem) fails" -msgstr "" +msgstr "當 predicate(elem) 失敗時 seq 的元素" #: ../../library/itertools.rst:60 msgid "``filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8``" @@ -244,7 +257,7 @@ msgstr "iterable[, key]" #: ../../library/itertools.rst:61 msgid "sub-iterators grouped by value of key(v)" -msgstr "" +msgstr "根據 key(v) 的值分組的子疊代器" #: ../../library/itertools.rst:62 msgid ":func:`islice`" @@ -256,7 +269,7 @@ msgstr "seq, [start,] stop [, step]" #: ../../library/itertools.rst:62 msgid "elements from seq[start:stop:step]" -msgstr "" +msgstr "seq[start:stop:step] 的元素" #: ../../library/itertools.rst:62 msgid "``islice('ABCDEFG', 2, None) → C D E F G``" @@ -296,7 +309,7 @@ msgstr ":func:`takewhile`" #: ../../library/itertools.rst:65 msgid "seq[0], seq[1], until predicate fails" -msgstr "" +msgstr "seq[0], seq[1],直到 predicate 失敗" #: ../../library/itertools.rst:65 msgid "``takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4``" @@ -312,7 +325,7 @@ msgstr "it, n" #: ../../library/itertools.rst:66 msgid "it1, it2, ... itn splits one iterator into n" -msgstr "" +msgstr "it1, it2, ... itn,將一個疊代器分成 n 個" #: ../../library/itertools.rst:67 msgid ":func:`zip_longest`" @@ -328,7 +341,7 @@ msgstr "``zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-``" #: ../../library/itertools.rst:70 msgid "**Combinatoric iterators:**" -msgstr "" +msgstr "**組合疊代器:**" #: ../../library/itertools.rst:75 msgid ":func:`product`" @@ -340,7 +353,7 @@ msgstr "p, q, ... [repeat=1]" #: ../../library/itertools.rst:75 msgid "cartesian product, equivalent to a nested for-loop" -msgstr "" +msgstr "笛卡爾乘積 (cartesian product),相當於巢狀的 for 迴圈" #: ../../library/itertools.rst:76 msgid ":func:`permutations`" @@ -352,7 +365,7 @@ msgstr "p[, r]" #: ../../library/itertools.rst:76 msgid "r-length tuples, all possible orderings, no repeated elements" -msgstr "" +msgstr "長度為 r 的元組,所有可能的定序,無重複元素" #: ../../library/itertools.rst:77 msgid ":func:`combinations`" @@ -364,7 +377,7 @@ msgstr "p, r" #: ../../library/itertools.rst:77 msgid "r-length tuples, in sorted order, no repeated elements" -msgstr "" +msgstr "長度為 r 的元組,按照排序過後的定序,無重複元素" #: ../../library/itertools.rst:78 msgid ":func:`combinations_with_replacement`" @@ -372,11 +385,11 @@ msgstr ":func:`combinations_with_replacement`" #: ../../library/itertools.rst:78 msgid "r-length tuples, in sorted order, with repeated elements" -msgstr "" +msgstr "長度為 r 的元組,按照排序過後的定序,有重複元素" #: ../../library/itertools.rst:82 msgid "Examples" -msgstr "" +msgstr "範例" #: ../../library/itertools.rst:84 msgid "``product('ABCD', repeat=2)``" @@ -412,7 +425,7 @@ msgstr "``AA AB AC AD BB BC BD CC CD DD``" #: ../../library/itertools.rst:94 msgid "Itertool Functions" -msgstr "" +msgstr "Itertool 函式" #: ../../library/itertools.rst:96 msgid "" @@ -420,24 +433,30 @@ msgid "" "provide streams of infinite length, so they should only be accessed by " "functions or loops that truncate the stream." msgstr "" +"以下的模組函式都會建構並回傳疊代器。一些函式提供無限長度的串流 (stream),因此" +"應僅由截斷串流的函式或迴圈來存取它們。" #: ../../library/itertools.rst:103 msgid "" "Make an iterator that returns accumulated sums or accumulated results from " "other binary functions." -msgstr "" +msgstr "建立一個回傳累積和的疊代器,或其他二進位函式的累積結果。" #: ../../library/itertools.rst:106 msgid "" "The *function* defaults to addition. The *function* should accept two " "arguments, an accumulated total and a value from the *iterable*." msgstr "" +"*function* 預設為加法。*function* 應接受兩個引數,即累積總和和來自 " +"*iterable* 的值。" #: ../../library/itertools.rst:109 msgid "" "If an *initial* value is provided, the accumulation will start with that " "value and the output will have one more element than the input iterable." msgstr "" +"如果提供了 *initial* 值,則累積將從該值開始,並且輸出的元素數將比輸入的可疊代" +"物件多一個。" #: ../../library/itertools.rst:113 ../../library/itertools.rst:182 #: ../../library/itertools.rst:236 ../../library/itertools.rst:279 @@ -455,26 +474,32 @@ msgid "" "amortization-schedule>`_ can be built by accumulating interest and applying " "payments:" msgstr "" +"*function* 引數可以被設定為 :func:`min` 以得到連續的最小值,設定為 :func:" +"`max` 以得到連續的最大值,或者設定為 :func:`operator.mul` 以得到連續的乘積。" +"也可以透過累積利息和付款來建立\\ `攤銷表 (Amortization tables) `_ :" #: ../../library/itertools.rst:153 msgid "" "See :func:`functools.reduce` for a similar function that returns only the " "final accumulated value." msgstr "" +"可參見 :func:`functools.reduce`,其是個類似的函式,但僅回傳最終的累積值。" #: ../../library/itertools.rst:158 msgid "Added the optional *function* parameter." -msgstr "新增選用的 *function* 參數。" +msgstr "新增可選的 *function* 參數。" #: ../../library/itertools.rst:161 msgid "Added the optional *initial* parameter." -msgstr "新增選用的 *initial* 參數。" +msgstr "新增可選的 *initial* 參數。" #: ../../library/itertools.rst:167 msgid "" "Batch data from the *iterable* into tuples of length *n*. The last batch may " "be shorter than *n*." msgstr "" +"將來自 *iterable* 的資料分批為長度為 *n* 的元組。最後一個批次可能比 *n* 短。" #: ../../library/itertools.rst:170 msgid "" @@ -483,6 +508,9 @@ msgid "" "is yielded as soon as the batch is full or when the input iterable is " "exhausted:" msgstr "" +"對輸入的可疊代物件進行迴圈,並將資料累積到大小為 *n* 的元組中。輸入是惰性地被" +"消耗 (consumed lazily) 的,會剛好足夠填充一批的資料。一旦批次填滿或輸入的可疊" +"代物件耗盡,就會 yield 出結果:" #: ../../library/itertools.rst:197 msgid "" @@ -491,16 +519,21 @@ msgid "" "are exhausted. Used for treating consecutive sequences as a single " "sequence. Roughly equivalent to::" msgstr "" +"建立一個疊代器,從第一個可疊代物件回傳元素直到其耗盡,然後繼續處理下一個可疊" +"代物件,直到所有可疊代物件都耗盡。用於將連續的序列做為單一序列處理。大致等價" +"於: ::" #: ../../library/itertools.rst:210 msgid "" "Alternate constructor for :func:`chain`. Gets chained inputs from a single " "iterable argument that is evaluated lazily. Roughly equivalent to::" msgstr "" +":func:`chain` 的另一個建構函式。從單個可疊代的引數中得到鏈接的輸入,該引數是" +"惰性計算的。大致等價於:" #: ../../library/itertools.rst:221 msgid "Return *r* length subsequences of elements from the input *iterable*." -msgstr "" +msgstr "從輸入 *iterable* 中回傳長度為 *r* 的元素的子序列。" #: ../../library/itertools.rst:223 msgid "" @@ -509,6 +542,9 @@ msgid "" "`math.comb` which computes ``n! / r! / (n - r)!`` when ``0 ≤ r ≤ n`` or zero " "when ``r > n``." msgstr "" +"輸出是 :func:`product` 的子序列,僅保留作為 *iterable* 子序列的條目。輸出的長" +"度由 :func:`math.comb` 給定,當 ``0 ≤ r ≤ n`` 時,計算 ``n! / r! / (n - r)!" +"``,當 ``r > n`` 時為零。" #: ../../library/itertools.rst:228 msgid "" @@ -516,6 +552,8 @@ msgid "" "order of the input *iterable*. If the input *iterable* is sorted, the output " "tuples will be produced in sorted order." msgstr "" +"根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " +"*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" #: ../../library/itertools.rst:232 msgid "" @@ -523,12 +561,15 @@ msgid "" "If the input elements are unique, there will be no repeated values within " "each combination." msgstr "" +"元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特" +"的,則每個組合內將不會有重複的值。" #: ../../library/itertools.rst:263 msgid "" "Return *r* length subsequences of elements from the input *iterable* " "allowing individual elements to be repeated more than once." msgstr "" +"回傳來自輸入 *iterable* 的長度為 *r* 的子序列,且允許個別元素重複多次。" #: ../../library/itertools.rst:266 msgid "" @@ -537,6 +578,9 @@ msgid "" "number of subsequence returned is ``(n + r - 1)! / r! / (n - 1)!`` when ``n " "> 0``." msgstr "" +"其輸出是一個 :func:`product` 的子序列,僅保留作為 *iterable* 子序列(可能有重" +"複元素)的條目。當 ``n > 0`` 時,回傳的子序列數量為 ``(n + r - 1)! / r! / (n " +"- 1)!``。" #: ../../library/itertools.rst:271 msgid "" @@ -544,6 +588,8 @@ msgid "" "order of the input *iterable*. if the input *iterable* is sorted, the output " "tuples will be produced in sorted order." msgstr "" +"根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " +"*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" #: ../../library/itertools.rst:275 msgid "" @@ -551,6 +597,8 @@ msgid "" "If the input elements are unique, the generated combinations will also be " "unique." msgstr "" +"元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特" +"的,生成的組合也將是獨特的。" #: ../../library/itertools.rst:305 msgid "" @@ -558,6 +606,8 @@ msgid "" "element in *selectors* is true. Stops when either the *data* or *selectors* " "iterables have been exhausted. Roughly equivalent to::" msgstr "" +"建立一個疊代器,回傳 *data* 中對應 *selectors* 的元素為真的元素。當 *data* " +"或 *selectors* 可疊代物件耗盡時停止。大致等價於: ::" #: ../../library/itertools.rst:319 msgid "" @@ -565,6 +615,8 @@ msgid "" "Can be used with :func:`map` to generate consecutive data points or with :" "func:`zip` to add sequence numbers. Roughly equivalent to::" msgstr "" +"建立一個疊代器,回傳從 *start* 開始的等差的值。可以與 :func:`map` 一起使用來" +"產生連續的資料點,或與 :func:`zip` 一起使用來增加序列號。大致等價於: ::" #: ../../library/itertools.rst:332 msgid "" @@ -572,6 +624,8 @@ msgid "" "achieved by substituting multiplicative code such as: ``(start + step * i " "for i in count())``." msgstr "" +"當用浮點數計數時,將上述程式碼替換為乘法有時可以獲得更好的精確度,例如:" +"``(start + step * i for i in count())``。" #: ../../library/itertools.rst:336 msgid "Added *step* argument and allowed non-integer arguments." @@ -583,12 +637,14 @@ msgid "" "each. When the iterable is exhausted, return elements from the saved copy. " "Repeats indefinitely. Roughly equivalent to::" msgstr "" +"建立一個疊代器,回傳 *iterable* 中的元素並保存每個元素的副本。當可疊代物件耗" +"盡時,從保存的副本中回傳元素。會無限次的重複。大致等價於: ::" #: ../../library/itertools.rst:356 msgid "" "This itertool may require significant auxiliary storage (depending on the " "length of the iterable)." -msgstr "" +msgstr "此 itertool 可能需要大量的輔助儲存空間(取決於可疊代物件的長度)。" #: ../../library/itertools.rst:362 msgid "" @@ -596,12 +652,16 @@ msgid "" "*predicate* is true and afterwards returns every element. Roughly " "equivalent to::" msgstr "" +"建立一個疊代器,在 *predicate* 為真時丟棄 *iterable* 中的元素,之後回傳每個元" +"素。大致等價於:" #: ../../library/itertools.rst:378 msgid "" "Note this does not produce *any* output until the predicate first becomes " "false, so this itertool may have a lengthy start-up time." msgstr "" +"注意,在 predicate 首次變為 False 之前,這不會產生\\ *任何*\\ 輸出,所以此 " +"itertool 可能會有較長的啟動時間。" #: ../../library/itertools.rst:384 msgid "" @@ -609,6 +669,8 @@ msgid "" "those for which the *predicate* returns a false value. If *predicate* is " "``None``, returns the items that are false. Roughly equivalent to::" msgstr "" +"建立一個疊代器,過濾 *iterable* 中的元素,僅回傳 *predicate* 為 False 值的元" +"素。如果 *predicate* 是 ``None``,則回傳為 False 的項目。大致等價於: ::" #: ../../library/itertools.rst:400 msgid "" @@ -618,6 +680,10 @@ msgid "" "returns the element unchanged. Generally, the iterable needs to already be " "sorted on the same key function." msgstr "" +"建立一個疊代器,回傳 *iterable* 中連續的鍵和群組。*key* 是一個為每個元素計算" +"鍵值的函式。如果其未指定或為 ``None``,則 *key* 預設為一個識別性函式 " +"(identity function),並回傳未被更改的元素。一般來說,可疊代物件需要已經用相" +"同的鍵函式進行排序。" #: ../../library/itertools.rst:406 msgid "" @@ -627,6 +693,10 @@ msgid "" "the same key function). That behavior differs from SQL's GROUP BY which " "aggregates common elements regardless of their input order." msgstr "" +":func:`groupby` 的操作類似於 Unix 中的 ``uniq`` 過濾器。每當鍵函式的值發生變" +"化時,它會產生一個 break 或新的群組(這就是為什麼通常需要使用相同的鍵函式對資" +"料進行排序)。這種行為不同於 SQL 的 GROUP BY,其無論輸入順序如何都會聚合相同" +"的元素。" #: ../../library/itertools.rst:412 msgid "" @@ -635,6 +705,9 @@ msgid "" "`groupby` object is advanced, the previous group is no longer visible. So, " "if that data is needed later, it should be stored as a list::" msgstr "" +"回傳的群組本身是一個與 :func:`groupby` 共享底層可疊代物件的疊代器。由於來源是" +"共享的,當 :func:`groupby` 物件前進時,前一個群組將不再可見。因此,如果之後需" +"要該資料,應將其儲存為串列: ::" #: ../../library/itertools.rst:424 msgid ":func:`groupby` is roughly equivalent to::"