Skip to main content

Questions tagged [attributes]

Questions on attributes of functions.

Filter by
Sorted by
Tagged with
1 vote
1 answer
73 views

Why does Expand messes up with multiplication when I clear the orderless attribute?

If I clear the commutativity of *: ClearAttributes[Times, Orderless] I get that ab and <...
Red Banana's user avatar
  • 5,421
2 votes
3 answers
89 views

Clearing a list of variables: Problems trying to control the order-of-evaluation [duplicate]

I am having trouble controlling the order of evaluation of mathematica expressions. What I would really like is a general solution, in the form of a pair of functions ...
J Tyson's user avatar
  • 132
3 votes
0 answers
46 views

Is this list of Formal Symbols complete? Which versions have unprotected Formal Symbols?

Formal Symbols are protected against being assigned values, making them handy for avoiding name collisions for things like fit parameters and pattern matching. Because formal symbols (and others) like ...
Tapiocaweasel's user avatar
4 votes
1 answer
127 views

How do I extract the domain values associated with a ColorDataFunction?

I want to extract the Domain values of 380 and 750 from the following ColorDataFunction: I'm missing something on the language-level—they don't seem to be Attributes, neither do they seem to be ...
Andrew Cheong's user avatar
1 vote
2 answers
81 views

Listable (on certain level) custom function

I wish to make custom listable function (for 2D points) with the next behaviour: ...
lesobrod's user avatar
  • 1,846
1 vote
1 answer
59 views

Setting PlotRange conditionally

I have several sets of data, and each set of data has a different scale (i.e., a different range of function values). I wish to plot each data set separately. I can do this using ...
Andrew's user avatar
  • 10.2k
0 votes
0 answers
47 views

Can I define relations without explicit transformation rules?

Is there an alternative way to use Mathematica for symbolic algebra, where instead of defining explicit transformation rules into 'canonical form', I can instead 'gently inform' Mathematica about ...
Myridium's user avatar
  • 1,099
4 votes
2 answers
129 views

Replace vs. ReplaceAll involving Flat

I'm aware that Replace and ReplaceAll behave differently as discussed in this question, but still get confused with the ...
Lacia's user avatar
  • 2,443
2 votes
0 answers
32 views

Attributes for functions with currying [duplicate]

Is there a way to set attributes for a function which holds for all arguments when currying? When evaluating, e.g., ...
Gert's user avatar
  • 1,620
11 votes
2 answers
212 views

How to make a function with two patterns listable?

Suppose that I have a function that has two patterns: disksConstantRadius[radius_][points_] := Disk[#, radius] & /@ points (noting that this would be better---...
Craig Carter's user avatar
  • 4,625
4 votes
1 answer
129 views

How to construct the HoldAll version of Information[]?

When building other functions I need the HoldAll version of Information, and the usual method seems not to work. Firstly as a ...
Lacia's user avatar
  • 2,443
4 votes
2 answers
190 views

How to define a function to be numeric when the input is purely symbolic

My goal is to have NumericQ[h[j]]=True for any j regardless of whether j may be symbolic with no defined value. Setting NumericQ[h[j_]]=True does not work and as I understand the NumericFunction ...
userrandrand's user avatar
  • 5,937
0 votes
1 answer
38 views

index as an attribute for a function containing data frame

Two questions. I have created a sample problem, and would be glad to have your help. I have 2 functions, fun1 and fun2, and one ...
Rupesh's user avatar
  • 887
2 votes
1 answer
75 views

SetAttribute for indicized variables? [duplicate]

Is there a way to SetAttributes to a function defined like this: fun[t_][x_,y_] Something like ...
mattiav27's user avatar
  • 6,757
0 votes
2 answers
134 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. ...
AlbertLew's user avatar
  • 483
1 vote
0 answers
163 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 ...
Alex97's user avatar
  • 420
1 vote
0 answers
46 views

Defining a function expression [duplicate]

I'm sure this has been answered before, but imagine I have the following function ...
sam wolfe's user avatar
  • 4,903
2 votes
1 answer
80 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 ...
imida k's user avatar
  • 4,315
1 vote
1 answer
53 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 ...
CMB's user avatar
  • 117
1 vote
1 answer
95 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: ...
z.v.'s user avatar
  • 189
2 votes
1 answer
81 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 ...
user106860's user avatar
2 votes
0 answers
90 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 ...
Giorgio Busoni's user avatar
1 vote
2 answers
67 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: ...
Jules Manson's user avatar
  • 2,467
1 vote
1 answer
58 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 ...
Jules Manson's user avatar
  • 2,467
5 votes
1 answer
136 views

head of a sequence

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
ExpressionCoder's user avatar
7 votes
2 answers
237 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: ...
pisco's user avatar
  • 229
1 vote
1 answer
58 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. ...
hal's user avatar
  • 783
1 vote
1 answer
308 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: ...
Einj's user avatar
  • 167
2 votes
2 answers
80 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: ...
Mr Puh's user avatar
  • 1,027
1 vote
1 answer
51 views

FilterRules works in DateListPlot but not in Plot

I just experience the following problem (this is a MWE just to illustrate). First DateListPlot ...
mgamer's user avatar
  • 5,603
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,800
2 votes
1 answer
58 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 ...
1010011010's user avatar
3 votes
2 answers
126 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 ...
dmtri's user avatar
  • 530
6 votes
1 answer
166 views

Is it possible to make listable Experimental`NumericalFunction?

I have been playing a bit with the undocumented function Experimental`CreateNumericalFunction and I wanted to know if somebody found a way to make generated ...
user12588's user avatar
  • 535
3 votes
2 answers
159 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 ...
imida k's user avatar
  • 4,315
2 votes
0 answers
41 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: ...
John Brown's user avatar
0 votes
1 answer
57 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? ...
Capivara Cometa's user avatar
2 votes
2 answers
147 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: ...
amator2357's user avatar
  • 1,394
0 votes
1 answer
65 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 ...
amator2357's user avatar
  • 1,394
2 votes
2 answers
75 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 ...
Paul B. Slater's user avatar
1 vote
2 answers
361 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 ...
Sarah's user avatar
  • 11
2 votes
1 answer
603 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 ...
lxy's user avatar
  • 189
1 vote
1 answer
61 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 ...
Logan's user avatar
  • 81
3 votes
1 answer
238 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 ...
a20's user avatar
  • 912
3 votes
1 answer
109 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 ...
t-smart's user avatar
  • 2,031
6 votes
2 answers
283 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 : ...
StarBucK's user avatar
  • 2,174
1 vote
1 answer
184 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 ...
Vlad G's user avatar
  • 13
0 votes
1 answer
75 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. ...
user61054's user avatar
  • 121
1 vote
1 answer
94 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: ...
NewJoiner's user avatar
1 vote
1 answer
232 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 ...
Tugrul Temel's user avatar
  • 6,233