# Questions tagged [attributes]

Questions on attributes of functions.

133 questions
Filter by
Sorted by
Tagged with
61 views

### SetAttribute for indicized variables? [duplicate]

Is there a way to SetAttributes to a function defined like this: fun[t_][x_,y_] Something like ...
• 6,104
68 views

### How can I remove the attributes "Orderless" from function Times stably and reliably?

Recently I have been doing some algebra of partitioned matrices, where product like below is common: where $A_{11}, A_{12}, X, Y$ are all partitioned matrix blocks thus all are matrices in essence. ...
• 289
1 vote
54 views

### How to make a function in terms of constants to inherit the attribute of being constant

I have defined two variables a and b: SetAttributes[a, Constant]; SetAtributes[b, Constant]; I have defined a function c as ...
• 340
1 vote
46 views

### Defining a function expression [duplicate]

I'm sure this has been answered before, but imagine I have the following function ...
• 4,138
72 views

### Construct really identical function (the same as Length)

In[1] Length[Unevaluated[1 + 1 + 1 + 1]] Out[1] 4 Q1) Can we construct a function named f, such that ...
• 2,451
1 vote
41 views

### HoldAll doesn't work for List or BlankSequence?

Consider the following function: f[arg_] := Print[Unevaluated[arg]]; Attributes[f] = HoldAll; The purpose of the function is to print the arguments unevaluated. In ...
• 107
1 vote
61 views

### Defining a two-variable function with a parity property

I would like to define a function that has the following property $f(-x,y)=f(x,-y)$. An example is $f(x,y)=x y$. For simple inputs, I can impose this easily enough as: ...
• 179
20 views

### How to set attributes for f[x_][y_]? [duplicate]

This doesn't hold expr: ...
• 1,055
36 views

### Example of when explicitly using MapThread is better than giving a function the Listable Attribute

This answer says that Listable just makes the function automatically apply MapThread to its arguments. Does anyone have a simple ...
• 707
71 views

### Ways to hide a secret token with some code?

I worked out a way to prompt notifications to peopel using my mathematica code that a new version is available. My code is in a private github repository, mathematica can access it using http requests ...
1 vote
51 views

### How to define a function that acts invidually on a varible number of arguments

I am trying to generate a function that applies to each argument for any number and type of arguments. The function might work like this: ...
• 1,647
1 vote
44 views

### Extracting name of symbol (variable name) from within a function not working

Abstract: I use a pattern so often that I needed to make a function for constructing it. A function getName[...] for extracting name of variable and value only ...
• 1,647
107 views

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
• 1,004
184 views

### Defining a function which is numerical on all vectors of arguments

There is an attribute NumericFunction in Mathematica that can do the following job: ...
• 229
1 vote
53 views

### Attributes for private functions

I am not sure if what I want to do can be done, but I thought to ask anyway. Note: I already have in hand a workaround, I was just wondering for the power/simplicity that Mathematica may provide. ...
• 743
1 vote
157 views

### Define symmetric function for a subset of variables

I apologize if this question has been asked already. I did some research and found some solutions but none of them was general enough for what I need. So, I defined the following function: ...
• 127
67 views

### Evaluation Control for interpolating functions

I would like to find the root of the third component of an interpolating function, here e.g. a BezierFunction p: ...
• 967
1 vote
39 views

### FilterRules works in DateListPlot but not in Plot

I just experience the following problem (this is a MWE just to illustrate). First DateListPlot ...
• 5,453
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 ...
• 1,760
46 views

### Using the value of OptionValue to clear a list

I'm currently using OptionValue inside a function, the Option I passed to the function should be cleared, then populated with ...
• 177
120 views

### When do functions apply on lists and when they do not

I have read in my lecture notes on Mathematica that functions (in the general sense) can be applied to lists of data and that they can return new lists with data. I have tried this and I have got ...
• 530
139 views

### Is it possible to make listable ExperimentalNumericalFunction?

I have been playing a bit with the undocumented function ExperimentalCreateNumericalFunction and I wanted to know if somebody found a way to make generated ...
• 457
134 views

### Construct a function that maps strings to functions

The main question is the last 5 lines (including codes) of this article. A[x_, y_] := Evaluate[ToExpression["x^2+y^2"]] A[3,4] Then the output becomes ...
• 2,451
36 views

### Mathematica: Remove argument from object with flat attribute

I have an object in mathematica with the attributes Flat and OneIdentity. I also defined the following substitutions: ...
1 vote
42 views

### Mapping function into elements of Sum

I'm trying to set an attribute that's valid for a generic sum, where n and f are arbitrary. de[A_ + B_] := de[A] + de[B] de@Sum[f[i], {i, n}] Is this possible? ...
142 views

### Returning the argument of a function if the argument is not of the right type

Best to give an example. Let us consider the function AdjacencyMatrix. When we pass, say a matrix to it, we get: ...
• 1,274
50 views

### Preventing an output of a function from being assigned a value

Say I have a function Example[n_Integer]:=n{x,y,z} Example@4 {4 x, 4 y, 4 z} Now, let us assign some values to ...
• 1,274
73 views

### How can one eliminate results in which symbols are assigned constant values?

As an exercise (pertaining to my posting Perform a constrained integration over \$[-1,1]^6--yielding a "separability probability"), I issued the command ...
• 2,205
1 vote
203 views

### Computation with arrays of numbers

My code is m = RandomVariate[NormalDistribution[], 100]; c = 0.1; f1 = RandomVariate[NormalDistribution[], 100]; F = Sqrt[c]*m + Sqrt[1 - c]*f1; I would like to ...
• 11
233 views

### Defining an operator with given properties

In symbolic derivations with Mathematica, one often needs to define an operator with some desired properties, which will be used to stand for a general function or transform. For example, I would ...
• 889
1 vote
51 views

### 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 ...
• 81
191 views

### Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
• 917
101 views

### HoldFirst being overridden by Activate [duplicate]

So here's the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it ...
• 1,941
218 views

### Flat attribute : example I don't understand

I am just beginning to learn about attributes of function in mathematica. I saw the example "Flat". But there is something I don't get : ...
• 1,973
1 vote
116 views

### Problem displaying Killing equations

What I'm trying to do is to compute the Killing equations and then solve them using DSolve to determine their solutions. I have a problem understanding where my Mathematica program doesn't work ...
• 13
72 views

### How can I get all the order of a list? [closed]

I have a list such as : {1,3,6}, then, I want to get all the orders of it, I do not know which function is easier. I have to try this code, but it is complex. ...
• 121
1 vote
90 views

### Pattern matching on Orderless functions

I'm trying the following pattern matching command: ReplaceList[Hold[b + a], Hold[x___ + y___] -> {{x}, {y}}] And Mathematica returns: ...
1 vote
153 views

### Pick the solutions that satisfy certain conditions

I have a large system of ODEs, and I find a large number of steady-state solutions. But many of them do not satisfy the condition that all the variables must have ...
• 4,391
544 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 ...
• 1,183
68 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 ...
• 1,183
106 views

### Subtle order-of-evaluation issues when pattern-matching with attributes

Related question concerning unrolling the tests that are shown below: Big and Little surprises when unrolling tests of pattern-matching and attributes Questions researched before posting this one: ...
• 8,561
95 views

### Big and Little surprises when unrolling tests of pattern-matching and attributes

Related question concerning interpretation of the substitutions: Subtle order-of-evaluation issues when pattern-matching with attributes Questions researched before posting this one: Orderless ...
• 8,561
1 vote
81 views

### Is it possible to modify the behavior of Listable?

Is it possible to achieve Thread-like behavior using the Listable attribute either on a symbol or in a pure function (or ...
• 3,980
90 views

### Modelling non-commutative products, CenterDot problem

I am trying to model certain non-commutative, but associative, structures with Mathematica. As a notation for the product I take CenterDot and add the attribute Flat since the product is associative. ...
• 33
104 views

### Concerning the Attribute Flat

Suppose we have a function f with the Attribute Flat. From my understanding, the following command should return all possible ways of rewriting ...
• 663
294 views

### 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 ...
• 914
186 views

### What are Flat Attribute best practices? [duplicate]

I would like, as an example, to build a Times-like function. Take the following example ...
• 889
482 views

### Define a distributive function?

Here is a related question, but not quite what I'm after. I would like to define a function f[x_] that has the distributive attribute, such that: ...
• 11.5k
83 views

### Listable function behaving in an unexpected way

For example, if I define a function like this: SetAttributes[func,Listable]; func@{{1,2},{3,4}} it gives the result like: ...
• 1,941