Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Enhancements
* ``FileNames`` returns a sorted list (#1250).
* ``FindRoot`` now receives several optional parameters like ``Method`` and ``MaxIterations``.
* ``FixedPoint`` now supports the ``SameTest`` option.
* ``Prepend`` works with ``DownValues`` Issue #1251
* ``Prime`` and ``PrimePi`` now accept a list parameter and have the ``NumericFunction`` attribute.
* ``Read`` with ``Hold[Expression]`` now supported. (#1242)
* ``ReplaceRepeated`` and ``FixedPoint`` now supports the ``MaxIteration`` option (#1260).
Expand Down
7 changes: 5 additions & 2 deletions mathics/builtin/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2918,8 +2918,11 @@ def apply(self, s, item, evaluation):
class Prepend(Builtin):
"""
<dl>
<dt>'Prepend[$expr$, $item$]'
<dd>returns $expr$ with $item$ prepended to its leaves.
<dt>'Prepend[$expr$, $item$]'
<dd>returns $expr$ with $item$ prepended to its leaves.

<dt>'Prepend[$expr$]'
<dd>'Prepend[$elem$][$expr$]' is equivalent to 'Prepend[$expr$,$elem$]'.
</dl>

'Prepend' is similar to 'Append', but adds $item$ to the beginning
Expand Down
24 changes: 24 additions & 0 deletions test/test_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from .helper import check_evaluation


def test_calculus():
for str_expr, str_expected, message in (
(
"DownValues[foo]={x_^2:>y}",
"{x_ ^ 2 :> y}",
"Issue #1251 part 1",
),
(
"PrependTo[DownValues[foo], {x_^3:>z}]",
"{{x_ ^ 3 :> z}, HoldPattern[x_ ^ 2] :> y}",
"Issue #1251 part 2",
),
(
"DownValues[foo]={x_^3:>y}",
"{x_ ^ 3 :> y}",
"Issue #1251 part 3",
),

):
check_evaluation(str_expr, str_expected, message)