Skip to content

Commit 517d3ec

Browse files
authored
Merge pull request #1364 from mathics/prepend-tidy
TIdy small omissions in PR #1251
2 parents d69ab0e + 0daac41 commit 517d3ec

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Enhancements
3535
* ``FileNames`` returns a sorted list (#1250).
3636
* ``FindRoot`` now receives several optional parameters like ``Method`` and ``MaxIterations``.
3737
* ``FixedPoint`` now supports the ``SameTest`` option.
38+
* ``Prepend`` works with ``DownValues`` Issue #1251
3839
* ``Prime`` and ``PrimePi`` now accept a list parameter and have the ``NumericFunction`` attribute.
3940
* ``Read`` with ``Hold[Expression]`` now supported. (#1242)
4041
* ``ReplaceRepeated`` and ``FixedPoint`` now supports the ``MaxIteration`` option (#1260).

mathics/builtin/lists.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,8 +2918,11 @@ def apply(self, s, item, evaluation):
29182918
class Prepend(Builtin):
29192919
"""
29202920
<dl>
2921-
<dt>'Prepend[$expr$, $item$]'
2922-
<dd>returns $expr$ with $item$ prepended to its leaves.
2921+
<dt>'Prepend[$expr$, $item$]'
2922+
<dd>returns $expr$ with $item$ prepended to its leaves.
2923+
2924+
<dt>'Prepend[$expr$]'
2925+
<dd>'Prepend[$elem$][$expr$]' is equivalent to 'Prepend[$expr$,$elem$]'.
29232926
</dl>
29242927
29252928
'Prepend' is similar to 'Append', but adds $item$ to the beginning

test/test_lists.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
from .helper import check_evaluation
3+
4+
5+
def test_calculus():
6+
for str_expr, str_expected, message in (
7+
(
8+
"DownValues[foo]={x_^2:>y}",
9+
"{x_ ^ 2 :> y}",
10+
"Issue #1251 part 1",
11+
),
12+
(
13+
"PrependTo[DownValues[foo], {x_^3:>z}]",
14+
"{{x_ ^ 3 :> z}, HoldPattern[x_ ^ 2] :> y}",
15+
"Issue #1251 part 2",
16+
),
17+
(
18+
"DownValues[foo]={x_^3:>y}",
19+
"{x_ ^ 3 :> y}",
20+
"Issue #1251 part 3",
21+
),
22+
23+
):
24+
check_evaluation(str_expr, str_expected, message)

0 commit comments

Comments
 (0)