Linked Questions

0 votes
0 answers
33 views

Except not working in Function [duplicate]

I have defined the CirclePlus operator as follows: ...
2 votes
1 answer
140 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, ...
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 ...
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 ...
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 ...
8 votes
2 answers
202 views

Recursion depth exceeded in pattern matching with attribute Flat

I am defining a linear associative multiplication operation Mult[]: ...
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 ...
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 ...
5 votes
2 answers
158 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 ...
12 votes
4 answers
537 views

Evaluation of Alternatives

I recently stumbled upon a few examples that suggest patterns containing Alternatives do not evaluate for individual alternatives. For example: ...
6 votes
2 answers
367 views

Why rule does not work if Flat attribute?

The following works: ...
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): ...
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? ...
23 votes
2 answers
753 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: ...