# Questions tagged [pure-function]

Questions about implementing or applying functions which: (1) always yield the same result for the same input, (2) are independent of outside information, and (3) produce no side effects.

221 questions
Filter by
Sorted by
Tagged with
900 views

### When is ##@@@##& more appropriate than ##@@##&?

When assigning attachment operators, I often run into confusing statements like ##@@##&, ##@@@##&, or even ...
• 35.6k
359 views

### Construct a pure function containing built-in 'Sequence'

I guessed the output for (Sequence[#, 7]&)[3] should be Sequence[3,7] But my guess was wrong. See the screenshot: And I ...
• 2,451
95 views

• 1,095
185 views

### Can Wolfram Language enforce pure functions?

Is there a feature in Wolfram Language that supports or enforces pure functions? WL has something that it calls "pure functions" in its documentation, but these are most emphatically not pure ...
• 12.7k
1 vote
75 views

### Slot numbers, pure functions [closed]

For the first line of code my function works fine on the list, but when trying to use Map I just keep getting an error (Function::slotn) basically saying there are not enough arguments for it to work, ...
• 199
459 views

### How to Force Evaluation of Derivative in a Pure Function Definition

Let's say I have a function f1 = #^2 &; I want to calculate its derivative, perform some manipulations and make the result a pure function. I try ...
• 338
32 views

### Behavior of ## changes inside Position function?

I don't understand the behavior of this following simple(?) example: ##&/@ {{0,1},{1,2}} Position[%,{1,2}] gives {{2}} ...
• 207
106 views

### Soft question: Is it feasible to have argument names with the shorthand (&) pure function syntax?

Nested pure functions can be messy, code length wise and syntax wise. It seems that the ampersand (&) in pure functions is always either proceeded by nothing: ...
216 views

### The use of SlotSequence in If[#1 > #2, ##] &

The below function when applied to a list of two elements, will output the maximum between the two: If[#1 > #2, ##] & For example: ...
• 303
104 views

### How to use a function as a value in an association? [closed]

I just started learning Mathematica. I was wondering if it is possible to use a function as an value in an association. Ideally, it would be something like this: ...
• 181
510 views

### How to convert list of variables x1, x2, x3 ,x4 ... x10 to list of x1_,x2_,x3_..x10_?

I'm writing a function where I need to give many inputs. I created a list of variables from Table function. My aim is to get ...
• 1,421
1 vote
97 views

### Is there a good reason why Slot[] is not an atomic expression?

Here's a good reason why I think it should be, Map[ If[AtomQ@#, #->"is an atom", #->"not an atom"]& , {"hello",Range@3, # &} , {-1} ] ...
• 1,970
380 views

### How to condition arguments of a pure function?

I would like to exclude the point {x=0,y=0} in the function definition ...
• 36.4k
439 views

### Pure functions instead of For loop

How to get following loop output using pure functions such as NestList? For[i = 0; v = 0, i < 4 && v < 4, i++; v++, Print[x^i + b^v]] and the ...
• 177
77 views

### Construction of symmetric function / matching function argument patterns

[Edited for clarification after comment] Suppose that the function f is defined as the linear combination of several translated/reflected functions starting from the primitive f0[x,y,z] ...
1 vote
235 views

### Pure functions vs normal functions [duplicate]

I am trying to understand the true difference/usage of a pure function vs a "normal" function. Besides the argument that a pure function is particularly handy when it comes to a single usage, are ...
• 743
498 views

### Replacement Rule for Functions

Attempting to write a rule that will substitute an undetermined function of several variables by some other undeterminate functions (also, of the same several variables). I can do it in an inelegant ...
• 171
789 views

### What's the meaning of #0? [closed]

Here's a line of code from a handbook written by Stephen Wolfram, which turns out to be very complicated for me. ...
• 113