Questions tagged [function-construction]
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.
2,538 questions
1
vote
1
answer
81
views
How to check if two edges have consistent orientation in all simple cycles of a graph?
How can I check whether two edges (tagged "c" and "d") have consistent orientation (either always the same ...
3
votes
2
answers
244
views
How to find x ranges where a function is one-to-one and its output is in a given range?
I have a list of functions like this:
...
4
votes
1
answer
127
views
Is there any efficient way to find cycle matroid of a graph?
Is there any efficient way to find cycle matroid of a graph?
A cycle matroid is basically all sets of edges in a graph that does not form a cycle.
The code below works pretty well for small graphs, ...
12
votes
4
answers
547
views
Recursive anonymous functions with |-> notation
We can define anonymous functions like this:
#^2+#+1 &
or like this
x |-> x^2+x+1
When we want to define a recursive ...
2
votes
5
answers
276
views
How to determine if a user-defined function, passed as an option, has a specific number of arguments
Let's say that I have a function f which is passed a user-defined function g which is originally passed as an option to some ...
0
votes
2
answers
109
views
How to extract the correct branch of a ConditionalExpression that a given range belongs to?
This function has two separate branches (not connected together):
func = ConditionalExpression[1/(1 - 2 x)^2, 0 < x < 1];
Given a range of ...
3
votes
1
answer
80
views
How to generate all graphs that decompose into a given list of subgraphs at articulation points?
Given a list of directed edge-tagged graphs gList like this:
...
5
votes
4
answers
340
views
How to find all possible splits of a list into sublists sharing exactly one element?
Given a list, I want to find all possible ways to split it into sublists such that:
Each sublist has length greater than 1.
Any two consecutive sublists share exactly one common element.
All elements ...
0
votes
0
answers
68
views
The cases of Piecewise function are not recognized when calculated in Table
Before describing the problem, a short background on how it pops up.
I am solving a PDE problem on the [0,1]x[0,1] domain. To this end, I want to find the decomposition of some derivatives of the ...
4
votes
2
answers
183
views
How can I reconstruct a graph from a list of fundamental cycles?
Assume that I have a list of simple cycle EdgeTaggedGraph objects called fundamentalCycles. I would like to construct a graph <...
7
votes
5
answers
587
views
Problem with a function calling another function
This is my code:
...
4
votes
3
answers
178
views
How to apply a list of binary operators to a list of arguments respecting standard operator precedence?
I have a list of binary functions such as {Plus, Times, Subtract} and a list of symbols like {a, b, c, d}. I want to construct ...
10
votes
11
answers
507
views
Riffle a list of binary functions into list of arguments to produce a result
Suppose I have a list of binary functions, e.g.
funcs = {Plus, Times, Power}
as well as a list of arguments, e.g.
...
4
votes
2
answers
162
views
Partitions of an integer into sums of nonnegative integer powers of its decimal digits
Problem statement: I am trying to write a function that calculates the number of distinct ways an integer can be expressed as a sum of nonnegative integer powers of its decimal digits and return this ...
2
votes
0
answers
92
views
How to define the derivative of variables inside an expression so chain rule can be correctly applied to the full expression
I don't use Mathematica as much and only use it for some specific tasks from time to time (mostly simplifying expressions and calculating integrals and derivatives).
Lets say I have an large ...