Linked Questions

5 votes
2 answers
157 views

How can Mathematica automatically replace NonCommutativeMultiply[x] with x for a single argument x? [duplicate]

By default, an expression like NoncommutativeMultiply[x] does not simplify to x, unlike ...
user27873's user avatar
  • 151
4 votes
1 answer
236 views

What are Flat Attribute best practices? [duplicate]

I would like, as an example, to build a Times-like function. Take the following example ...
MaPo's user avatar
  • 909
2 votes
0 answers
71 views

non listable plus and times [duplicate]

I am trying to create my own Plus and Times functions, which are identical to the built in ones with the exception that they are ...
Jansen's user avatar
  • 1,223
0 votes
0 answers
45 views

How to make a Flat function return x when evaluated as f[x]? [duplicate]

With SetAttributes[f, Flat], f[a_] can get matched to f of any number arguments. How can I ...
The Vee's user avatar
  • 1,790
0 votes
0 answers
33 views

Except not working in Function [duplicate]

I have defined the CirclePlus operator as follows: ...
infinitezero's user avatar
  • 1,419
23 votes
2 answers
750 views

SetAttributes[f,Flat]: Why the order dependence?

I'm experiencing a strange phenomenon. Here's a (quite artificial) test case: The following definition work just fine: ...
celtschk's user avatar
  • 19.1k
12 votes
4 answers
531 views

Evaluation of Alternatives

I recently stumbled upon a few examples that suggest patterns containing Alternatives do not evaluate for individual alternatives. For example: ...
jjc385's user avatar
  • 3,473
16 votes
1 answer
639 views

Orderless pattern matching

The MMA docs state that "In matching patterns with Orderless functions, all possible orders of arguments are tried". Why then does the following not work? ...
sn6uv's user avatar
  • 565
7 votes
4 answers
570 views

partial numerical evaluation

Context The following is an issue I have come across many times and still do not have a satisfactory solution for. The context of it is this. Let's say we have an equation, a linear ODE for the ...
Jansen's user avatar
  • 1,223
8 votes
2 answers
202 views

Recursion depth exceeded in pattern matching with attribute Flat

I am defining a linear associative multiplication operation Mult[]: ...
bcp's user avatar
  • 781
1 vote
1 answer
2k views

Why does Mathematica add Hold to the result of my user defined symbol?

In the code below I have defined a symbol that multiplies two block-matrices (I can't use the builtin Dot since Dot assumes that the matrix coefficients commute): ...
user24877's user avatar
6 votes
2 answers
366 views

Why rule does not work if Flat attribute?

The following works: ...
Suzan Cioc's user avatar
  • 2,023
10 votes
2 answers
126 views

Functions in a different context are replaced with infix forms of their namesake in System`

So, in an attempt to help out Fabian with his question, I did what I often do, and created a new symbol in the Pillsy` package that I could play with. Since it was ...
Pillsy's user avatar
  • 18.5k
2 votes
1 answer
139 views

How can we create a Mathematica function that can accept 0 or more arguments?

How can we create a Mathematica function that can accept 0 or more arguments in the same way the Times function does? Specially, I'd like to replace the Times function to work with Reals, Complexes, ...
GarouDan's user avatar
  • 1,536