Skip to content

Commit 5a044f8

Browse files
committed
Go over more builtin docs...
* `PowersRepresentations`` * ``ReverseSort``
1 parent 7755cb9 commit 5a044f8

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ By `@davidar <https://github.com/davidar>`_:
8888
``mathics`` command line
8989
++++++++++++++++++++++++
9090

91+
Option ``--post-mortem`` was added which goes into the `trepan3k
92+
debugger <https https://pypi.org/project/trepan3k/>`_ on an
93+
unrecoverable error. This option is available on other front-ends..
94+
9195
WMA Compatibility
9296
-----------------
9397

mathics/builtin/numbers/numbertheory.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,21 @@ class PowersRepresentations(Builtin):
831831
<dd>represent $n$ as a sum of $k$ non-negative integers raised to the power of $p$.
832832
</dl>
833833
834+
Get the ways licence plate number 1729 can be represented as the sum of two cubes:
834835
>> PowersRepresentations[1729, 2, 3]
835836
= {{1, 12}, {9, 10}}
836-
>> PowersRepresentations[50, 3, 2]
837-
= {{0, 1, 7}, {0, 5, 5}, {3, 4, 5}}
837+
838+
See <url>:1729:https://en.wikipedia.org/wiki/1729_(number)</url> for the full backstory.
839+
840+
Demonstrate the validity of the Pythagorian triple: 3^2 + 4^2 == 5^2
841+
>> PowersRepresentations[25, 2, 2]
842+
= {{0, 5}, {3, 4}}
843+
844+
Since 0 is allowed in the sum, 'PowersRepresentations[$n$, $k$+1, $p$]' is includes \
845+
'PowersRepresentations[$n$, $k$, $p$]' with by inserting a zero element at the beginning:
846+
847+
>> PowersRepresentations[25, 3, 2]
848+
= {{0, 0, 5}, {0, 3, 4}}
838849
"""
839850

840851
attributes = A_PROTECTED | A_READ_PROTECTED

mathics/builtin/statistics/orderstats.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,21 @@ class ReverseSort(Builtin):
279279
280280
>> ReverseSort[{c, b, d, a}]
281281
= {d, c, b, a}
282+
283+
You can specify a binary comparison function:
284+
>> ReverseSort[{1, 2, 0, 3}, Less]
285+
= {3, 2, 1, 0}
286+
287+
Using 'Greater' for the above, reverses the reverse sort:
288+
>> ReverseSort[{1, 2, 0, 3}, Greater]
289+
= {0, 1, 2, 3}
290+
291+
See also <url>:Sort:
292+
/doc/reference-of-built-in-symbols/descriptive-statistics/order-statistics/sort/</url>.
282293
"""
283294

284295
attributes = A_PROTECTED
285-
summary_text = "reverse sort"
296+
summary_text = "sort in reverse order"
286297

287298
rules = {
288299
"ReverseSort[list_]": "Reverse[Sort[list]]",
@@ -318,10 +329,13 @@ class Sort(Builtin):
318329
= {2 + c_, 1 + b__}
319330
>> Sort[{x_ + n_*y_, x_ + y_}, PatternsOrderedQ]
320331
= {x_ + n_ y_, x_ + y_}
332+
333+
See also <url>:ReverseSort:
334+
/doc/reference-of-built-in-symbols/descriptive-statistics/order-statistics/reversesort/</url>.
321335
"""
322336

323337
attributes = A_PROTECTED
324-
summary_text = "sort lexicographically or with any comparison function"
338+
summary_text = "sort lexicographically or with a comparison function"
325339

326340
def eval(self, list, evaluation: Evaluation):
327341
"Sort[list_]"

0 commit comments

Comments
 (0)