Message Boards Message Boards

1 Reply
0 Total Likes
View groups...
Share this post:

Cleared Attribute "Listable" - acts like it is still set

Posted 9 years ago


for some formal calculations, I temporarily disabled the Listable Attributes of Plus and Times. This works very well, however I fail to understand the following output? I would expect the output to be 3*{a, b} + {a, b}, again. What am I missing?

In[1327]:= 3*{a, b} + {a, b}

Out[1327]= {4 a, 4 b}

Many Thanks!

POSTED BY: Urban Seifert

Patching builtins sometimes works, but it's inviting unexpected behavior. If you're trying to mix symbols with explicit arrays, it's probably better to wrap the arrays in a function that prevents Listable from operating. The actual wrapper doesn't matter as long as it's passive, but MatrixForm is convenient, and makes pretty output, too. Try this:

ab = MatrixForm[{a, b}]
3*ab + ab

And then, to unwrap, just do something like:

% /. MatrixForm -> Identity
POSTED BY: John Doty
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract