Repository: sympy/sympy

Issue:
MathMLContentPrinter does not handle sympy.Lambda correctly
```python
    from sympy import Lambda
    from sympy.abc import x, y
    from sympy.printing.mathml import MathMLContentPrinter

    sym = Lambda((x, y), x * y)
    mathml = MathMLContentPrinter().doprint(sym)
    print(mathml)
```

Actual: 
```xml
<lambda><tuple><ci>x</ci><ci>y</ci></tuple><apply><times/><ci>x</ci><ci>y</ci></apply></lambda>
```

[Expected](https://www.w3.org/TR/MathML2/chapter4.html#id.4.2.1.7): 
```xml
<lambda><bvar><ci>x</ci></bvar><bvar><ci>y</ci></bvar><apply><times/><ci>x</ci><ci>y</ci></apply></lambda>
```

~I will submit a patch shortly.~ Proposed fix in  #25062.

Discussion:

Patch:
diff --git a/.mailmap b/.mailmap
index 9f6ea36991..e30818ee07 100644
--- a/.mailmap
+++ b/.mailmap
@@ -474,6 +474,7 @@ Daniel Hyams <dhyams@gmail.com> dhyams <dhyams@gmail.com>
 Daniel Ingram <ingramds@appstate.edu>
 Daniel Mahler <dmahler@gmail.com>
 Daniel Sears <highpost@users.noreply.github.com>
+Daniel Weindl <daniel.weindl@helmholtz-muenchen.de>
 Daniel Wennberg <daniel.wennberg@gmail.com>
 Danny Hermes <daniel.j.hermes@gmail.com>
 Darshan Chaudhary <deathbullet@gmail.com>
diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py
index 16e269566c..01e53e288a 100644
--- a/sympy/printing/mathml.py
+++ b/sympy/printing/mathml.py
@@ -574,6 +574,17 @@ def _print_ProductSet(self, e):
             x.appendChild(self._print(arg))
         return x
 
+    def _print_Lambda(self, e):
+        # MathML reference for the lambda element:
+        # https://www.w3.org/TR/MathML2/chapter4.html#id.4.2.1.7
+        x = self.dom.createElement(self.mathml_tag(e))
+        for arg in e.signature:
+            x_1 = self.dom.createElement('bvar')
+            x_1.appendChild(self._print(arg))
+            x.appendChild(x_1)
+        x.appendChild(self._print(e.expr))
+        return x
+
     # XXX Symmetric difference is not supported for MathML content printers.
 
 
@@ -634,6 +645,7 @@ def mathml_tag(self, e):
             'mathieuc': 'C',
             'mathieusprime': 'S&#x2032;',
             'mathieucprime': 'C&#x2032;',
+            'Lambda': 'lambda',
         }
 
         def mul_symbol_selection():


Test patch:
diff --git a/sympy/printing/tests/test_mathml.py b/sympy/printing/tests/test_mathml.py
index 8d5049de23..438a6e4a1d 100644
--- a/sympy/printing/tests/test_mathml.py
+++ b/sympy/printing/tests/test_mathml.py
@@ -130,6 +130,16 @@ def test_content_mathml_functions():
     assert mml_3.childNodes[1].childNodes[
         0].nodeName == 'ci'  # below bvar there's <ci>x/ci>
 
+    mml_4 = mp._print(Lambda((x, y), x * y))
+    assert mml_4.nodeName == 'lambda'
+    assert mml_4.childNodes[0].nodeName == 'bvar'
+    assert mml_4.childNodes[0].childNodes[
+        0].nodeName == 'ci'  # below bvar there's <ci>x/ci>
+    assert mml_4.childNodes[1].nodeName == 'bvar'
+    assert mml_4.childNodes[1].childNodes[
+        0].nodeName == 'ci'  # below bvar there's <ci>y/ci>
+    assert mml_4.childNodes[2].nodeName == 'apply'
+
 
 def test_content_mathml_limits():
     # XXX No unevaluated limits