# Tagged Questions

For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

121 views

### How to properly define this function of function

I encountered real problem at first, and here is the toy example variable argument stored some expression that is generated from other parts of the program. I ...
68 views

### Automating game simulation, using previous results [closed]

Based on this question on MSE, I would like to simulate a game whereby player $2$ enters a number, so as to test the strategy. The basis for this is the factor game online here. ...
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, ...
110 views

### How to get name of “named row” in Dataset for function applied to each row

After some calculations and a GroupBy I have a Dataset that is structured like this. ...
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, ...
56 views

### Memoized function with function parameter [duplicate]

I have some code that takes a function and uses the function to do some complicated computation. Thus, I wish to store this so I don't have to repeat this. Below, it is more simple than my real ...
151 views

### How to find period of a discrete sequence?

For example, {1,2,3,4,5,6,7,8} has period 1, the base is {1} {1,2,4,5,7,8,10,11} has period 3, the base is {1,2} I ...
59 views

### Setting a One Dimensional Function Equal to a Constant over a Specific Range

I am trying to take the output from NDSolve and create a variable equal to the solution except for a certain range of values. Here is the code I am trying to use ...
52 views

100 views

### How to delay the definition of a function from the time of package initialization to when it is first called

I am writing a package where a couple defined functions take a very long time define at initialization time (because they are large CompiledFunctions). However ...
194 views

### How to define functions with a list of arguments

I wante to define several functions, all of them with the same arguments, for example: f[a_, b_, c_]:= ... g[a_, b_, c_]:= ... h[a_, b_, c_]:= ... How can I do ...
368 views

### How to define a periodic function from an interval to Play (monotonic) sound

I would like to define a function on an interval and then duplicate it on other intervals of the same length in order to define a (generally discontinuous) periodic function, from which I could get a (...
131 views

### Programming a MaxMin Linear Optimization

I want to program a function for a two-player game. Basically it's like this: . Each player has an array of options, and the result of the game is based on both players choices. So heres my most ...
189 views

### Name rewriting for Function fails in closure

At its heart, Mathematica is a dynamically scoped language. While the choice of dynamic scope for Mathematica is very much a defensible one, lexical scope is too useful to do without, and Mathematica ...
206 views

### How to define a conditioned function that returns one when x is integer and zero otherwise? [closed]

What is the simplest way to define a conditioned function that returns one when x is integer and zero otherwise? I'm doing it wrong: ...
73 views

### Using functionals in Mathematica [duplicate]

I recently installed Mathematica and I wanted to define a functional in it. This is what I did: ...
436 views

### Skipping “middle” Optional Arguments

Is there a way to call a function where the "middle" arguments should use their default value while specifying values for the "right-most" arguments? For example, given this function: ...
68 views

### Create a function for $\Pi^{-1}(n)$

Is it possible to create a function that gives the inverse of pP[x_] := Sum[PrimePi[x^(1/k)]/k, {k, 1, Floor[Log2[x]]}] i.e., a function that plots ...
51 views

66 views

...
56 views

### Is there a IsDefinedQ function? [duplicate]

I have a function which is a bit expensive to calculate. I want to translate and integrate. I want to translate by values on a grid, store the values of the integral and refine the grid. That is, I ...