# Tagged Questions

The tag has no usage guidance.

4answers
2k views

### Do people actually use UpValues?

I know what they are and how to define them. They have to serve some purpose - else why include them? But I never used them and all examples on this site and the docs never show a practical use of <...
2answers
613 views

### Copying one symbol into another

I would like to know how can I completely copy one Symbol to another. When I say copy, a refer to UpValues, DownValues, ...
3answers
1k views

### Emulating R data frame getters with UpValues

What's the best way to emulate R's data frames functionality? This includes the ability to select rows and columns in a 2-dimensional table by the string identifiers positioned typically in the first ...
2answers
361 views

### What does f_[whoCalled]^:=f really mean?

I came across the following post by John Doty in this Google Groups discussion: On Friday, January 11, 2013 8:23:16 PM UTC-7, amzoti wrote: It is clear the Mathematica uses Lisp as one ...
1answer
548 views

### Upvalues, TagSet and UpSet, what's the difference, when should a use each?

Some of the big mysteries of Universe Mathematica for me is the application of UpValues. I know about this question and know the very poor Mathematica documentation on that. I'm very curious to know ...
2answers
266 views

### Why isn't Lookup treated like other symbols?

With Mathematica 10, I wanted to overload Lookup using TagSetDelayed, but it doesn't work. For instance, if I define two objects ...
1answer
128 views

### $\tt AddTo$ regression in v10

As we know we can assign special addition rules to symbols by using UpValues: ...
3answers
423 views

### How can I hold UpValues but evaluate other expressions?

Consider these definitions: own = "OwnValue"; down[_] = "DownValue"; sub[_][_] = "SubValue"; N[n] = 3.14; _[___, up, ___] ^= "UpValue"; The attribute ...
1answer
220 views

### How to deal with bad arguments when a function's UpValues is a pure-function?

In practice, I needs to define the UpValues of a user-defined function. For instance, the operation of function like differential formula , expansion and so on. ...
4answers
588 views

### How to use pattern matching to assign values to Subscript[f,x_]?

I want to define two subscripted functions Subscript[f,1] and Subscript[f,2]. To keep the assignments local, I would like to ...
2answers
353 views

### Using up-values and down-values

I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists. The following rules produce the result e[2].f[] ...
2answers
207 views

### How to define UpValues in a different context from within a package

I'm trying to create a function (in a package) to import a lot of data and create a symbol with UpValues to return specific results about the data. I've got it working fine in a regular notebook, but ...
1answer
91 views

### Strange behavior of UpSetDelayed together with MakeBoxes

In order to answer this question, I just stumbled into the world of UpValues. Though I managed to find a solution for the problem, I'm confused by my own code now 囧,...
2answers
297 views

### Make Sinc'[0] return 0 instead of Indeterminate

I want Sinc'[0] to return 0, but instead it returns Indeterminate. I've tried Unprotect[Sinc] Unprotect[Derivative] Derivative[1][Sinc][0] ^= 0 But it doesn't ...
1answer
106 views

### How to assign up-values for Derivative?

I have defined several custom analytic functions. Here is the simplest example: ln[x_, a_?NumericQ] := Piecewise[{{Log[x], Re[a] > 0}, {-Log[1/x], True}}] ...
2answers
115 views

### How to prevent $\text{Quantity}$ calculations from converting units

I have an accrual calculation that I would like to preserve the units even though they are of the same dimension (e.g. time). For example, I would like the following ...
2answers
249 views

### How to customize derivative behavior via upvalues?

I'm having trouble getting customized derivatives (defined using upvalues) to behave in sane ways. By this I mean that I'd like to define a derivative using an upvalue and then have Mathematica apply ...
1answer
165 views

### Problem overloading D[] using UpValues

First I define an entry of UpValues overloading D[] for expressions with head ftest: ...
3answers
3k views

### How to force 2+2=5

I was looking at this question (writing a program such that 2 + 2 = 5) and tried to write something in Mathematica, but I couldn't get something to work without completely replacing ...
1answer
113 views

### Strange behaviour of UpSet [duplicate]

Can anyone explain what is going on here? I want to modify TensorRank for IdentityMatrix, but it fails on its first attempt: <...
1answer
120 views

### Add options to upvalues

I have some objects that I want to present in TeXForm. Thus, it is easily to do as follows: YoungTableau/:TeXForm[YoungTableau[diagram_]] However, what if I ...
1answer
121 views

### How to create fast functions based on units?

Using units is a good means for rapidly developing code, since it provides some error control. Hovewer, using Mathamatica functions containing units appears to be copmutationally inefficient. ...
2answers
172 views

### Why this upvalue doesn't escape from Sum?

Probably a hard question, but I decide to cry out loud :). This is actually another problem I encountered when answering this question. Consider the following transform rule stored as an upvalue: <...
1answer
214 views

### How to tame the wild MMA?

MMA is a free country. But TOO free sometimes. Just as an example: Clear[a] a[x_] == a[y_] ^:= Round[x] == Round[y] {a[3] == a[3.01], a[3] == a[4]} is {True, ...
1answer
205 views

### Inheritance in Mathematica using pattern matching on UpValues

Edit: I think in my original post, I missed emphasizing the main point. This is mainly a pattern matching question. If you're interested in the 'why' of this question, please read the original post ...
2answers
405 views

### Overloading conjugate operator for a particular function

I trying to modify the behaviour of the built-in Conjugate[] operator on a particular function I have defined, to take into account that some of its variables are ...
1answer
92 views

### Upvalues for Missing do not work with Dataset

Consider the following Dataset: d = Dataset[<| 1 -> Missing[], 2 -> 1.0, 3 -> 4.0 |>] And the following Upvalue for Missing: ...
1answer
206 views

### Access curated or locally stored data with curated data functions?

Say I have a toy package, something like: ...
2answers
76 views

### Local modification of built-in command via UpValue

I have a computationally intense function f that returns a matrix. Sometimes only the diagonal is needed, which is faster to compute, thus there's a syntax for f to ...
3answers
143 views

### UpValues evaluation with Dot operator

I would like to simplify some database notation, and I'm doing some tests with UpValues for that. For example, if I set this Upvalue fot tab1: ...
1answer
127 views

### Why is held expression evaluated?

Context: I'm studying non-linear dynamics. As part of a bigger problem, I'd like to generate lists of the form {{deq, ic1}, {deq, ic2}, ...}, where ...
1answer
35 views

1answer
111 views

### Experiment with TagSetDelayed involving Part

Reading Associating Definitions With Different Symbols, I was intrigued by this: You can think of upvalues as a way to implement certain aspects of object-oriented programming. A symbol like ...
1answer
44 views

### What workarounds are there to TagSetDelayed::tagpos?

My program creates an object based on an Association, with a custom head: g = Gate[<| "key1" -> val1 |>] I have ...
1answer
142 views

### Can a Symbol own OwnValues that don't evaluate when it's the head of an expression?

I believe this a question that most of us have encountered when we were beginners but forgot when we got more familiar with Mathematica. We know the notation $y=y(x)$ for functions, where $y$ here ...
2answers
68 views

### Changing a tag when one function is passed into another using UpValues

I have two complicated functions f[x,y] and g[t]. Before the main evaluation code in g[expr]...
0answers
38 views

### Setting derivative of function equal to 0 at x=0 using UpValues

I'm trying to set the derivative of a function to zero at a specified point. This will act as an initial condition for an algorithm I'm writing: so I'm specifying the value of the function at x=0, and ...
0answers
51 views

### Upvalues and order of interpretation

I'm trying to use UpValues to improve the usability of some code, but I am running into an issue where the order of the UpValues is important, and I am not sure if it is my understanding or a ...
2answers
101 views

### How do I use a passed-in symbol as a tag to define UpValues?

ClearAll@foo; foo[tag_] := ( tag /: tag[i_] := tag[[i]] ); a = {7, 8, 9}; foo[a]; a[2] I wanted the above to output 8, ...
0answers
74 views

### Memoization and upvalues

Can I store an algorithm to one variable and the result as an upvalue to another? With regard to the problematic code below (real algorithm and argument test omitted), I would like to store the ...