From 8292bc981e723bc1322312031c51aee0f9df2c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 17 Nov 2024 04:22:48 +0100 Subject: [PATCH] List --- README.md | 7 ++++--- index.html | 11 ++++++----- pdf/remove_links.py | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e252bd4..561a241 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ List ``` ```python - = max() # Returns largest element. Also max(, ...). + = max() # Returns largest element. Also min(, ...). = sum() # Returns sum of elements. Also math.prod(). ``` @@ -61,10 +61,11 @@ sorted_by_both = sorted(, key=lambda el: (el[1], el[0])) flatter_list = list(itertools.chain.from_iterable()) ``` * **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 - = len() # Returns number of items. Also works on other collections. + = len() # Returns number of items. Also works on dict, set and string. = .count() # Returns number of occurrences. Also `if in : ...`. = .index() # Returns index of the first occurrence or raises ValueError. = .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 @@
- +
@@ -114,7 +114,7 @@ <list> = sorted(<collection>) # Returns new list with sorted elements. <iter> = reversed(<list>) # Returns reversed iterator of elements. -
<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>).
 
elementwise_sum  = [sum(pair) for pair in zip(list_a, list_b)]
@@ -124,9 +124,10 @@ flatter_list     = list(itertools.chain.from_iterable(<list>))
 
  • For details about sort(), sorted(), min() and max() see sortable.
  • -
  • Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.
  • +
  • Module operator has function itemgetter() that can replace listed lambdas.
  • +
  • This text uses the term 'collection' instead of 'iterable'. For rationale see collection.
-
<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.
@@ -2923,7 +2924,7 @@ $ deactivate                # Deactivates the active
  
 
   
- +
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 = { 'For details about sort(), sorted(), min() and max() see sortable.': 'For details about sort(), sorted(), min() and max() see sortable (p. 16).', - 'Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.': 'Module \'operator\' (p. 31) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions (p. 11) above.', + 'Module operator has function itemgetter() that can replace listed lambdas.': 'Module \'operator\' has function itemgetter() that can replace listed lambdas (p. 11, 31).', + 'This text uses the term \'collection\' instead of \'iterable\'. For rationale see collection.': 'This text uses the term \'collection\' instead of \'iterable\'. For rationale see collection (p. 18).', 'Adding \'!r\' to the expression converts object to string by calling its repr() method.': 'Adding \'!r\' to the expression converts object to string by calling its repr() method.', 'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable, but is usually implemented as a function that returns a closure.', '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.': '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.',