Linked Questions

181
votes
2answers
10k views

What is the distinction between DownValues, UpValues, SubValues, and OwnValues?

When reading through the documentation, you often encounter the phrases DownValues, UpValues, ...
68
votes
7answers
4k views

Functions vs. patterns

Every time I define a new function, I wonder which construct I should use: true functions obtained by using Function, or rule-based syntax. For example, these are ...
50
votes
3answers
4k views

Changing Values in an Association using Map

I am trying to change the value of one key in an association based on the value of another key in that association. So if my association starts as: ...
36
votes
2answers
2k views

Define parameterized function

I would like to be able to define the gain function of a system from its parameters. Specifically, I'd like to define a function that accepts two inputs, call them $b$ and $w$, and returns a function ...
41
votes
2answers
2k views

What are all the “magic” Symbols in the Mathematica language?

Leonid Shifrin once wrote (excerpted): (Unevaluated) is one of a very few "magic symbols", along with Sequence and ...
8
votes
4answers
867 views

Prepend 0 to sublists

My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's. The file I'm working is a CSV containing around 50K sublists of length 35. I've ...
23
votes
2answers
529 views

Why doesn't a Composition[] hold its arguments and what can be done about it?

Now that Composition (also RightComposition) has shorthand syntax I am more inclined to use it, however what I feel should be ...
17
votes
3answers
358 views

Is it possible to change the order that symbol definitions are checked? (DownValues vs UpValues)

Suppose I have the function f with the following definition assigned to it: ...
19
votes
1answer
361 views

What is the difference between defining a function and specifying the type of argument, versus applying a test to that argument?

Say I want to create a function that evaluates differently based on what type of argument is given. I've found two ways of doing this, ...
8
votes
1answer
808 views

Pure functions are not functions?

According to the manual: "HoldAll is an attribute which specifies that all arguments to a function are to be maintained in an unevaluated form." The following code yields, as expected, ...
8
votes
2answers
230 views

Keywords to find documentation for this syntax

Mathematica allows this syntax, but I cannot find any documentation (or books) that discuss the various uses/advantages of it ...
12
votes
4answers
296 views

Implement settable properties

I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to ...
4
votes
2answers
145 views

Generating compiled functions from inactive expressions

I am working on a project in which I need to dynamically generate CompiledFunctions from Inactive expressions. For example, I ...
5
votes
1answer
731 views

How can I overload a function with multiple bracket-slots so f[a][b] and f[a] can coexist?

Maybe this is not even possible: I want to create a function f that can have two input brackets like: f[a_][b_:1]:= a*b and ...
6
votes
2answers
220 views

How to select specific subvalues from a function definition

Consider: h[1][tag1] = 1; h[1][tag2] = 2; h[2][tag1] = 3; h[2][tag2] = 4; Is there a fast way to obtain downvalues for only h[1], or h[2]? For example ...

15 30 50 per page