3
$\begingroup$

I need an operation $\tilde{}$ that lifts another operation (for example, the sum, but this does not have to be limited to real numbers) in the sense that $\widetilde{ (x \oplus y)} = \tilde x + \tilde y $.

I tried to implement this

Til[x⊕y] 
Til[x_CirclePlus] := Til[#] & /@ x
Til[x ⊕ y] 

where Til is the tilde. But this yields $ \widetilde{ (x \oplus y)} = \tilde x \color{red}\oplus \tilde y $.

  • How to replace the red plus by a normal sum?

  • Alternatively, how can I read each of the summands without using x_CirclePlus?

$\endgroup$
4
  • 2
    $\begingroup$ Til[CirclePlus[a_, b_]] := Til[a] + Til[b]? If I understand you correctly, you would not need your other definition if you use this one. $\endgroup$
    – MarcoB
    Jun 3 '20 at 16:33
  • 3
    $\begingroup$ As a further generalization of @Marco's proposal: Til[CirclePlus[args__]] := Apply[Plus, Til /@ {args}]. $\endgroup$ Jun 3 '20 at 16:42
  • $\begingroup$ Great, that's the solution. I don't know why I doubted Til cannot read directly the arguments of CirclePlus. As for the second, I didn't know that syntax, sorry. Both work. $\endgroup$
    – João
    Jun 3 '20 at 17:03
  • 2
    $\begingroup$ Despite your second bullet, the following works too and is close to your original: Til[x_CirclePlus] := Til /@ Plus@@x; it is just a slightly shorter version of @J.M.'s Til[CirlePlus[args__]]:=Plus@@(Til/@{args}) $\endgroup$ Jun 4 '20 at 3:04
3
$\begingroup$

As mentioned in comments:

ClearAll[Til]
Til[CirclePlus[args__]] := Apply[Plus, Til /@ {args}]
$\endgroup$
2
$\begingroup$
ClearAll[Til]

Til[a_⊕b___] := Til /@ Unevaluated[a + b]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.