diff --git a/README.md b/README.md index e252bd4..561a241 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ List ``` ```python -<el> = max(<collection>) # Returns largest element. Also max(<el_1>, ...). +<el> = max(<collection>) # Returns largest element. Also min(<el_1>, ...). <num> = sum(<collection>) # Returns sum of elements. Also math.prod(<coll>). ``` @@ -61,10 +61,11 @@ sorted_by_both = sorted(<collection>, key=lambda el: (el[1], el[0])) flatter_list = list(itertools.chain.from_iterable(<list>)) ``` * **For details about sort(), sorted(), min() and max() see [sortable](#sortable).** -* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as [lambda](#lambda) expressions above.** +* **Module [operator](#operator) has function itemgetter() that can replace listed [lambdas](#lambda).** +* **This text uses the term 'collection' instead of 'iterable'. For rationale see [collection](#collection).** ```python -<int> = len(<list>) # Returns number of items. Also works on other collections. +<int> = len(<list>) # Returns number of items. Also works on dict, set and string. <int> = <list>.count(<el>) # Returns number of occurrences. Also `if <el> in <coll>: ...`. <int> = <list>.index(<el>) # Returns index of the first occurrence or raises ValueError. <el> = <list>.pop() # Removes and returns item from the end or at index if passed. diff --git a/index.html b/index.html index 916bc4d..d086a81 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@ <body> <header> - <aside>November 14, 2024</aside> + <aside>November 17, 2024</aside> <a href="https://gto76.github.io" rel="author">Jure Šorn</a> </header> @@ -114,7 +114,7 @@ <list> = sorted(<collection>) <span class="hljs-comment"># Returns new list with sorted elements.</span> <iter> = reversed(<list>) <span class="hljs-comment"># Returns reversed iterator of elements.</span> </code></pre> -<pre><code class="python language-python hljs"><el> = max(<collection>) <span class="hljs-comment"># Returns largest element. Also max(<el_1>, ...).</span> +<pre><code class="python language-python hljs"><el> = max(<collection>) <span class="hljs-comment"># Returns largest element. Also min(<el_1>, ...).</span> <num> = sum(<collection>) <span class="hljs-comment"># Returns sum of elements. Also math.prod(<coll>).</span> </code></pre> <pre><code class="python language-python hljs">elementwise_sum = [sum(pair) <span class="hljs-keyword">for</span> pair <span class="hljs-keyword">in</span> zip(list_a, list_b)] @@ -124,9 +124,10 @@ flatter_list = list(itertools.chain.from_iterable(<list>)) </code></pre> <ul> <li><strong>For details about sort(), sorted(), min() and max() see <a href="#sortable">sortable</a>.</strong></li> -<li><strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as <a href="#lambda">lambda</a> expressions above.</strong></li> +<li><strong>Module <a href="#operator">operator</a> has function itemgetter() that can replace listed <a href="#lambda">lambdas</a>.</strong></li> +<li><strong>This text uses the term 'collection' instead of 'iterable'. For rationale see <a href="#collection">collection</a>.</strong></li> </ul> -<pre><code class="python language-python hljs"><int> = len(<list>) <span class="hljs-comment"># Returns number of items. Also works on other collections.</span> +<pre><code class="python language-python hljs"><int> = len(<list>) <span class="hljs-comment"># Returns number of items. Also works on dict, set and string.</span> <int> = <list>.count(<el>) <span class="hljs-comment"># Returns number of occurrences. Also `if <el> in <coll>: ...`.</span> <int> = <list>.index(<el>) <span class="hljs-comment"># Returns index of the first occurrence or raises ValueError.</span> <el> = <list>.pop() <span class="hljs-comment"># Removes and returns item from the end or at index if passed.</span> @@ -2923,7 +2924,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active <footer> - <aside>November 14, 2024</aside> + <aside>November 17, 2024</aside> <a href="https://gto76.github.io" rel="author">Jure Šorn</a> </footer> diff --git a/pdf/remove_links.py b/pdf/remove_links.py index 984c53a..e31507e 100755 --- a/pdf/remove_links.py +++ b/pdf/remove_links.py @@ -8,7 +8,8 @@ from pathlib import Path MATCHES = { '<strong>For details about sort(), sorted(), min() and max() see <a href="#sortable">sortable</a>.</strong>': '<strong>For details about sort(), sorted(), min() and max() see sortable (p. 16).</strong>', - '<strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as <a href="#lambda">lambda</a> expressions above.</strong>': '<strong>Module \'operator\' (p. 31) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions (p. 11) above.</strong>', + '<strong>Module <a href="#operator">operator</a> has function itemgetter() that can replace listed <a href="#lambda">lambdas</a>.</strong>': '<strong>Module \'operator\' has function itemgetter() that can replace listed lambdas (p. 11, 31).</strong>', + '<strong>This text uses the term \'collection\' instead of \'iterable\'. For rationale see <a href="#collection">collection</a>.</strong>': '<strong>This text uses the term \'collection\' instead of \'iterable\'. For rationale see collection (p. 18).</strong>', '<strong>Adding <code class="python hljs"><span class="hljs-string">\'!r\'</span></code> to the expression converts object to string by calling its <a href="#class">repr()</a> method.</strong>': '<strong>Adding <code class="python hljs"><span class="hljs-string">\'!r\'</span></code> to the expression converts object to string by calling its repr() method.</strong>', '<strong>It can be any <a href="#callable">callable</a>, but is usually implemented as a function that returns a <a href="#closure">closure</a>.</strong>': '<strong>It can be any callable, but is usually implemented as a function that returns a closure.</strong>', '<strong>Hints are used by type checkers like <a href="https://pypi.org/project/mypy/">mypy</a>, data validation libraries such as <a href="https://pypi.org/project/pydantic/">Pydantic</a> and lately also by <a href="https://pypi.org/project/Cython/">Cython</a> compiler. However, they are not enforced by CPython interpreter.</strong>': '<strong>Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.</strong>',