Questions tagged [attributes]

Questions on attributes of functions.

Questions on attributes of functions in Mathematica. This includes choosing the appropriate attributes for a task and also setting (SetAttributes, Protect), querying (Attributes) and removing attibutes (ClearAttributes, Unprotect) of functions. Attributes can control argument evaluation (HoldFirst, HoldRest, HoldAll, etc.), protect function definition (ReadProtected, Protected and Locked), specify argument listability (Listable), commutativity (Orderless), associativity (Flat), pattern equivalency (OneIdentity), and other numeric properties (Constant, NumericFunction).

General questions on how to define functions should use the tag .

Useful links:

141 questions
11
votes
1 answer

Custom attributes?

Is it possible to assign custom attributes to symbols and check them later? SetAttributes[a, b] says Attributes::attnf: b is not a known attribute.
Suzan Cioc
  • 2,023
  • 1
  • 16
  • 21
10
votes
2 answers

Mathematica: How to create a function that returns a property similar to how LinearModelFit works?

I'm trying to write a custom function in Mathematica, myFunc[x]. I want to be able to define properties of the function so that the user can call myFunc[x]["Property"] and have it return the value stored in Property. Basically I'm looking for the…
dthor
  • 971
  • 7
  • 17
9
votes
2 answers

Given the OneIdentity attribute why is GCD[a] evaluated to GCD[a]?

GCD has attribute OneIdentity, so why doesn't GCD[a] evaluate to a?
axelclk
  • 297
  • 1
  • 8
6
votes
2 answers

Error changing Attribute of ParabolicCylinderD after unprotecting

This is related to why-changing-the-order-of-format-causes-error but it seems to be a new issue so posting a new question. Of all the symbols that I changed its Format by unprotecting it first, then protecting it afterwords, only ParabolicCylinderD…
Nasser
  • 143,286
  • 11
  • 154
  • 359
4
votes
2 answers

Make Times non-commutative only for a specific set of expressions

I'm making a small hacky notebook and want to avoid using external libraries. In my notebook, I'd like multiplication to be non-commutative only for a particular family of expressions whilst still using Times (not NonCommutativeMultiply). The…
Anti Earth
  • 1,211
  • 6
  • 13
3
votes
1 answer

Make input function listable

I have a function taking a function as input as well as other values, e.g. f2[f_, a_, b_, c_, d_] = f[{a, b}, c, d]; Of course, the behavior differs for f1 being Listable or not. So if I define f1[x_, y_, z_] = If[x > 0, x*y + z, -x + y + z] it…
riddleculous
  • 393
  • 1
  • 9
2
votes
1 answer

SetAttribute for indicized variables?

Is there a way to SetAttributes to a function defined like this: fun[t_][x_,y_] Something like SetAttrubutes[fun[t_],Listable]?
mattiav27
  • 6,677
  • 3
  • 28
  • 64
1
vote
1 answer

ScrollPosition Synchronization

Two separate Panes. Pane-1 with vertical scroll bars and Pane-2 no scroll bars. Need to sync the scrolling between them. When scrolling Pane-1 vertically, need to have pane 2 automatically scroll to the same ScrollPosition. Is there a technique I…
Logan
  • 81
  • 1
0
votes
1 answer

Set attribute of a function to be a specific equation that it fulfills

I would like to define a function f(x,y,z) by its attribute, namely by the specific equation f(b,c,d)f(a,b+c,d)f(a,b,c)=f(a+b,c,d)f(a,b,c+d) for all a,b,c,d. Is it pssible to set this specific attribute to f?
Bipolar Minds
  • 265
  • 1
  • 6