Questions about DownValues which specify function definitions for symbols.
1
vote
2answers
68 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 real.
...
1
vote
1answer
67 views
Given a list of date and value pairs, efficiently sum the values by date
I have a list of date & value pairs. There can be multiple entries for each day. Sample data can be generated with the following:
...
8
votes
1answer
92 views
Unset variable by its name given as a string
Unlike the function Clear, the function Unset does not work for string patterns. Given the name of a variable as a string, how can you unset the corresponding variable? Example:
Given:
...
6
votes
2answers
114 views
DownValue “associative array” to list? [duplicate]
I have a "sparse array" like this
arr[1.5]=0.4, arr[3.5]=0.7, arr[7]=0.3
which is not really a sparse array since the keys are not all integers. This is like a ...
3
votes
1answer
112 views
Downvalues vs. Scoping for Functions
Regarding my recent question on using a default value for a function argument when a pattern was not met yielded some interesting answers, but the general consensus was "Yes this can be done, but ...
3
votes
2answers
108 views
Get DownValues that do not involve patterns?
Say I have a function with a few definitions that also implements memoization:
f[x_] := f[x] = x^2
f[x_, y_] := f[x, y] = x^2 + y^2
I then apply the function to ...
7
votes
2answers
210 views
How to get the list of defined values for an indexed variable?
I would like a table with rational indexes - thus it would be practical to use a dictionary, which, in Mathematica are implemented with the indexed variables. I would like to be able to do:
...
21
votes
0answers
300 views
How is pattern specificity decided?
Mathematica has a notion of pattern specificity, which is a partial ordering on patterns.
The rules (e.g. DownValues, ...
1
vote
0answers
69 views
How safe are ReadProtected and Locked symbols? [duplicate]
Possible Duplicate:
How to distribute proprietary Mathematica code
I suspect that there is a way to expose the down values of such symbols with an attack along these lines:
...
9
votes
1answer
153 views
Selectively clear DownValues
How can I clear a subset of a symbol's DownValues ?
For example, suppose I have created some DownValues for $f$ like this:
...
14
votes
5answers
768 views
The difference between 0. and 0
I have a function for which 0 is a special case:
f[A___, 0, B___] := 0
But since I am doing numerics, sometimes in the course ...
6
votes
3answers
172 views
Organizing similar datasets using DownValues instead of Contexts
In his answer to this question, Leonid helped me find a way to programmatically generate contexts for holding sets of symbols with the same names. Perhaps a simpler way is to use ...