Questions tagged [attributes]

Questions on attributes of functions.

Filter by
Sorted by
Tagged with
1 vote
2 answers
76 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,501
1 vote
1 answer
56 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.5k
0 votes
0 answers
46 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,089
4 votes
2 answers
126 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,233
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,480
11 votes
2 answers
209 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,250
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,233
4 votes
2 answers
167 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,807
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
74 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,637
0 votes
2 answers
126 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
  • 473
1 vote
0 answers
147 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
  • 390
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,553
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
  • 3,945
1 vote
1 answer
52 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
85 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
77 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
88 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
65 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,437
1 vote
1 answer
55 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,437
5 votes
1 answer
134 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
231 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
296 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
79 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,017
1 vote
1 answer
50 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,593
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,790
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
123 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
162 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
  • 585
3 votes
2 answers
158 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
  • 3,945
2 votes
0 answers
40 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
49 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,354
0 votes
1 answer
59 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,354
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
345 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
512 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
  • 165
1 vote
1 answer
60 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
235 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
  • 927
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
277 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,164
1 vote
1 answer
181 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
74 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
93 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
224 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,184
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 ...
Jansen's user avatar
  • 1,223
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 ...
Jansen's user avatar
  • 1,223
5 votes
1 answer
117 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: ...
Reb.Cabin's user avatar
  • 8,661
3 votes
1 answer
106 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 ...
Reb.Cabin's user avatar
  • 8,661