Questions on attributes of functions.

learn more… | top users | synonyms

0
votes
0answers
30 views

`{Protected, ReadProtected}` System symbols give “Set::write: ”Tag * in *[v_] is Protected" on first try

Run Quit, then Unprotect@AbelianGroup; AbelianGroup[v_] = 0; Protect@AbelianGroup; where instead of ...
2
votes
1answer
51 views

What Heads do not have the attribute NumericFunction, but still give True in NumericQ?

The following expressions give True in the NumericQ test: ...
8
votes
2answers
255 views

How do I restore HoldAll, HoldFirst, HoldRest attributes of Inactivated functions

Let f be defined as follows: ClearAll[f]; SetAttributes[f, HoldFirst]; f[1+1] (* f[1+1] *) The ...
5
votes
2answers
97 views

Defining a symbolic inner product

So I have some rules for a symbolic inner product that work for quite a lot of cases: ...
4
votes
0answers
92 views

Argument attributes for pure functions [duplicate]

In his book, Leonid Shifrin says: One important limitation of the # - & notation for the pure functions is that it is ...
6
votes
1answer
38 views

How is Attributes protected and yet can still be set?

The Attributes function itself has the attributes: Attributes[Attributes] ...
7
votes
1answer
138 views

Map vs listable [duplicate]

What's the difference between setting a function's attribute as Listable and using Map? I understand that ...
4
votes
2answers
80 views

MatchQ failing in some cases with Hold [duplicate]

Could someone clarify why the first of these MatchQ finds a match whereas the second does not? (I'm using version 10.0, in case that matters.) ...
6
votes
1answer
90 views

Where are examples of packages that are locked?

I wanted to see some packaged whose core functions are locked, but I couldn't find any. Is anyone protecting their code with the Locked and ...
4
votes
0answers
56 views

How to get f[x] to match with f[c_., x] when OneIdentity doesn't match

After setting: SetAttributes[f, OneIdentity] Default[f] = 1; We have the following successful matches: ...
0
votes
1answer
51 views

Manipulate curves [duplicate]

I want to draw curves with manipulation. When I use the following code, I receive nothing. ...
5
votes
1answer
148 views

Attributes with Pattern test

Probably this question has no application but it helps understand basic issues about Attributes and functions. I was writing a piece of code where I accidently ...
12
votes
4answers
222 views

How to define a function that is Listable for some but not all arguments?

I want to define a function f[x,y] that is Listable for only the first argument, not the second. If we use ...
12
votes
2answers
145 views

Orderless and Sequence

I just ran into the following subtlety. Let us consider a function f with attribute Orderless. ...
9
votes
1answer
151 views

Why there is only `HoldFirst` but no `HoldSecond`, `HoldThird`, …`HoldN`?

I feel that this must be a duplicate. But I just can't find such a post. Mathematica has HoldFirst, HoldRest, ...
2
votes
0answers
61 views

Follow-up to “How to differentiate formally?”: Efficiency concern

In link to "how to differentiate formally?" and particularly to the answer by @Jens, I want to do something like this: ...
6
votes
2answers
99 views

How do Dynamic Attributes work?

Reading in the doc, it is mentioned in the example of Dynamic that this way of writing the code does not work: ...
19
votes
2answers
333 views

Pattern does not match with Orderless head

Why does the following pattern matching not succeed? ...
2
votes
0answers
58 views

Documentation on the attribute OneIdentity [duplicate]

The documentation on the attribute OneIdentity says OneIdentity is an attribute that can be assigned to a symbol f to ...
2
votes
2answers
134 views

make trace of a matrix listable?

I have a list of 2 by 2 matrices and I want the list of their traces. I have been using Map[Tr,mylistofmatrices] But I wonder if there is a way to make ...
4
votes
2answers
175 views

How do I display function application with square brackets in traditional form?

If I type C[x, y] // TraditionalForm I get something that looks like C[x, y] But if I type ...
7
votes
2answers
229 views

Built in function without Attributes Listable works as if it has Attributes Listable

Can Built-in function works as if it has Attributes Listable even if it doesn't have that ...
5
votes
1answer
192 views

How to understand the difference between Sqrt and Log after ClearAll them

I came across this post, here I change the last line of the code Unprotect[Sqrt]; Sqrt[x_] = "blahblah"; Protect[Sqrt]; Sqrt[2] "blahblah" ...
7
votes
2answers
240 views

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

GCD has attribute OneIdentity so I expected GCD[a] being evaluated to a?
12
votes
1answer
312 views

Orderless pattern matching

The MMA docs state that "In matching patterns with Orderless functions, all possible orders of arguments are tried". Why then does the following not work? ...
4
votes
1answer
76 views

How Unevaluated works Through its Attributes?

Check this example: ...
4
votes
1answer
101 views

Slowdown of Flat attributed function

I was trying to write an associative function f using the attribute Flat. ...
0
votes
1answer
30 views

Numeric-type attributes for symbols (analog of NumericFunction)

Is there an attribute for symbols that makes NumericQ give True? For example Pi and ...
13
votes
2answers
213 views

Listable functions thread over Associations; is this documented?

Thanks to a somewhat misapplied use of MapThread I learned of this behavior: ...
12
votes
2answers
348 views

How to restore function attributes to default

Adding an attribute to a function is easy and clearing attribute is easy also. But I don't know really how to restore the attributes of a function to its defaults. All I do is quit the kernel or close ...
4
votes
1answer
184 views

Listable on first level [duplicate]

I have some function which take List as input. f[l_List]:=someActions[l] I need apply this function to a list of lists. Now I ...
2
votes
1answer
826 views

Why is either Listable or HoldFirst not working?

Starting with a fresh kernel, I evaluate the following: ...
2
votes
1answer
203 views

Plotting attributes of vertices in WattsStrogatzGraphDistribution[n, p, k]

I have a graph WS = RandomGraph[WattsStrogatzGraphDistribution[n, p, k]]. I need to plot several characteristics of each v: the ...
8
votes
3answers
561 views

How to protect functions in a Mathematica Package?

I'm writing a Mathematica Package with many functions, but only two can be seen/public. I have: ...
9
votes
1answer
137 views

Why does $Failed have attribute HoldAll?

Why does $Failed have attribute HoldAll? Are there typical situations where $Failed is ...
9
votes
2answers
434 views

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 ...
5
votes
2answers
165 views

Strange Behavior when making Equal Listable in Pick

While trying to make this problem more efficient I tried different methods and dabbled with making Greater and Equal ...
12
votes
2answers
196 views

How can one write a robust ListableQ function?

I would like to have a test that determines if a particular function is Listable. In the case of Symbols this is merely a matter of checking Attributes. ...
9
votes
1answer
104 views

Apply N only outside a certain function

1 + f[1] // N gives 1. + f[1.] I don't want the argument of f evaluated by N; I ...
8
votes
1answer
192 views

The Flat Attribute, Unevaluated and the Evaluation Process

To make this question easy to follow let's give some symbols a couple attributes. Attributes[f] = {Flat}; Attributes[s] = {Orderless}; Now consider the following:...
16
votes
2answers
413 views

Pure function with attributes of arbitrary number of arguments: Is it possible?

Mathematica allows to define pure function, like Function[{a, b},Length[Unevaluated@a]{b}][1+2,2+3] (* ==> {0} *) Pure functions in Mathematica can take an ...
2
votes
1answer
106 views

Map and Scan ignore HoldFirst

I am trying to write a simple function that takes a list of data and outputs it to a file. I'd like the name of the file to be the same as the variable that holds the list. It seems that giving a ...
5
votes
1answer
88 views

Why is NHoldFirst not propagated to symbolic derivatives?

I encountered a nasty problem that N cannot evaluate expressions containing a symbolic Derivative of a multi-parameter function ...
5
votes
2answers
235 views

Why rule does not work if Flat attribute?

The following works: ...
9
votes
1answer
259 views

Custom attributes?

Is it possible to assign custom attributes to symbols and check them later? SetAttributes[a, b] says ...
5
votes
3answers
1k views

Define an 'inner product' with AngleBracket

I want to define my own little 'Inner Product' function satisfying properties of linearity and commutativity, and I'd like to use the "$\langle$" and "$\rangle$" symbols to output my results. For ...
15
votes
1answer
251 views

Why are the attributes of Plot changing?

In version 9, with a newly started Mathematica session, try the following code: ...
32
votes
1answer
417 views

Quickly look-up usages, options and attributes of symbols

When I'm writing code in the front-end, I find myself very often looking up the list of options of a symbol over and over again in the documentation center. In most cases you find there a list of ...
27
votes
5answers
3k views

how to differentiate formally?

I have been wrapping my head around this for a while now and I have not found a solution so far. I want to work with an arbitrary number of variables in mathematica and use some built in functions. ...
6
votes
2answers
373 views

Force integration to be linear over sum?

Is there an obvious way to force Mathematica to separately integrate the terms in a sum? According to the docs, When part of a sum cannot be integrated explicitly, the whole sum will stay ...