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.
14
votes
6answers
562 views
Using patterns in pure functions
Pure functions may be handy if you don't want to assign your function a name. For example I would calculate $x(x-1)$ for some numbers $x$ by
...
7
votes
3answers
279 views
Composition of TransformationFunctions
I have a number of rotations computed by rot = RotationTransform[theta, point], and I would like to compose them to produce one function that is the composition of ...
4
votes
1answer
166 views
What's the most intelligent way to store the information of a selfmade graph?
I have a very long list of element, say $a1,a2, a3$,..., and they are all connected in that each is the child of many parents. E.g. $a74$ is associated with $a2,a55,a71$, and also contains ...
9
votes
2answers
239 views
Defining a ForEach function
Consider the following function definition:
ForEach[iterators__] := Table[#, iterators] &;
Two questions about it:
I. It works perfectly if you call it like ...
7
votes
3answers
285 views
Inverting a function in a certain region
InverseFunction works well for globally invertible functions, like
f = 2*# + 2 &;
InverseFunction[f]
...
12
votes
1answer
195 views
How to make a function like Set, but with a Block construct for the pattern names
How can we define a function that works like f[x_]=ComputeSomething[x] and treats x as a variable that does not have a value? ...
26
votes
6answers
969 views
How can I create a function with optional arguments and options?
Is it possible to create a function with optional arguments that also takes options?
Here is a simple example. I have a function f with option "g". It also has ...
10
votes
5answers
316 views
define a function from a list
I would like to create a mapping from a list and I am wondering if there is a slick way of doing it.
For example, consider the list
...
28
votes
6answers
914 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 ...

