I have defined my own algebra using the unused operators $\oplus$ and $\otimes$. During evaluation, lists pop up which have the structure


which I would like to expand to


I tried

{a_, {b_\[CirclePlus]c_}, d_} := {a, b, d}\[CirclePlus]{a, c, d}

but this returns the error

SetDelayed::shape: Lists {a__,{b_\[CirclePlus]c_},d__} and {a,b,d}\[CirclePlus]{a,c,d} are not the same shape.

How can I define such an expansion rule?

  • $\begingroup$ That's a specific problem with List. It will work with most other heads, e.g., list[a_, list[b_\[CirclePlus]c_], d_] := list[a, b, d]\[CirclePlus]list[a, c, d] is fine... $\endgroup$ Mar 10, 2018 at 10:45

1 Answer 1


This works:

CirclePlus /: {a__, b_\[CirclePlus]c_, d__} := {a, b, d}\[CirclePlus]{a, c, d}

Without the internal list though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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