New answers tagged

0 votes

How to pass arguments of outer function into inner function implicitly?

I really think this is a bad idea, but if you truly want "implicit", you may need to let your special symbols live "outside" your functions. You could do this by setting up a ...
lericr's user avatar
  • 26.4k
1 vote

How to pass arguments of outer function into inner function implicitly?

I feel like I must be missing something, because it sounds like you just want a straightforward passing of arguments: ...
lericr's user avatar
  • 26.4k
1 vote

Combine list elements preceding a specific element

...
E. Chan-López's user avatar
1 vote

Combine list elements preceding a specific element

...
eldo's user avatar
  • 61.3k
1 vote

How to set optional variables in Function?

Okay, taking your question at face value, you can do the following if you're willing to make the following assumption: All of the arguments with default values are at the right/tail end of the ...
lericr's user avatar
  • 26.4k
3 votes

Mapping function across its arguments

Permutations[expr,{1}] Or : expr~Permutations~{1} {f[a], f[b], f[c]}
Reda.Kebbaj's user avatar
5 votes
Accepted

How to remove non-loop vertices in a graph?

KCoreComponents Subgraph[graph, KCoreComponents[graph, 2]]
kglr's user avatar
  • 392k
3 votes

How to remove non-loop vertices in a graph?

I just found a way to do it. I'm still curious if there are other approaches or better improvements for my code, though. ...
internet's user avatar
  • 703
1 vote

Mapping function across its arguments

Using TakeList: expr = f[a, b, c]; TakeList[expr, ConstantArray[1, Length@expr]] {f[a], f[b], f[c]} Other thoughts: ...
Syed's user avatar
  • 48.8k
4 votes

Mapping function across its arguments

expr = f[a, b, c]; expr[[0]] /@ List @@ expr {f[a], f[b], f[c]} First @ Cases[expr, x_[y__] :> x /@ {y}, {0}] {f[a], f[b], ...
eldo's user avatar
  • 61.3k
8 votes

Mapping function across its arguments

expr = f[a, b, c]; Using BlockMap BlockMap[# &, expr, 1] Using ...
vindobona's user avatar
  • 2,491
8 votes

Mapping function across its arguments

expr[[0]]/@{Delete[0][expr]} (* {f[a],f[b],f[c]} *) or ...
user1066's user avatar
  • 16.8k
6 votes

Mapping function across its arguments

...
MelaGo's user avatar
  • 7,971
3 votes

Mapping function across its arguments

Thread[f[a, b, c] /. y_[x__] -> y[{x}]] ??
Alexei Boulbitch's user avatar
12 votes

Mapping function across its arguments

Using Subsets: expr = f[a, b, c]; Subsets[expr, {1}] (*{f[a], f[b], f[c]}*) Or using ...
E. Chan-López's user avatar
22 votes
Accepted

Mapping function across its arguments

Tuples[expr, 1] (* {f[a], f[b], f[c]} *)
Karl's user avatar
  • 911
9 votes

Mapping function across its arguments

Some alternatives: f[a, b, c] // #[[0]] /@ Level[#, 1] & (* {f[a], f[b], f[c]} *) f[a, b, c] // #[[0]] /@ List @@ # & (* {f[a], f[b], f[c]} *) Sharper, ...
Goofy's user avatar
  • 2,642
11 votes

Mapping function across its arguments

Operate[Map[#]@*List &, expr]
lericr's user avatar
  • 26.4k
1 vote

Use Fold and If to define "remove three repetitions"

l1 = {0, 1, 1, 2, 2, 2, 1}; l2 = {0, 1, 1, 2, 2, 2, 1, 4, 4, 4}; l3 = {0, 1, 1, 2, 2, 2, 2, 1, 4, 4, 4}; Another way to do this using ...
E. Chan-López's user avatar
1 vote

Use Fold and If to define "remove three repetitions"

1. Only one triple list = {0, 1, 1, 2, 2, 2, 1}; Using SubsetReplace (new in 12.1) and ...
eldo's user avatar
  • 61.3k
1 vote

A polynomial with positive integer powers is being displayed as a transcedental function (LerchPhi)

What happens is that Mathematica is actually able to explicitly compute your series, which seems to contain two instances of LerchPhi (after you do ...
Domen's user avatar
  • 21.9k
1 vote

A polynomial with positive integer powers is being displayed as a transcedental function (LerchPhi)

g[x_, n_?IntegerQ] := x^(n - 1) - Sum[((2 i - 1)/(i + n - 1) x^(i - 1)), {i, 1, n - 1}] g[x, 3] g[x, n] g[x, n] /. n -> 3 ...
azerbajdzan's user avatar
  • 13.5k
1 vote

How to generate a series of bisection points of a given line segment?

Using Subdivide: The table called divs has all the subdivisions whose last entry is being used to depict the most subdivided ...
Syed's user avatar
  • 48.8k
3 votes

How to indicate table continuation in the middle with torn edge paper effect or something similar

...
kglr's user avatar
  • 392k
3 votes
Accepted

Put tiny, hidden information on notebook

You can use CellTags. The following sets tag of the first cell in notebook: ...
azerbajdzan's user avatar
  • 13.5k
5 votes
Accepted

Distinguish .nb that has been saved from new .nb

Quiet@NotebookFileName[] returns name of current notebook in the case it was saved or $Failed in the case it was never saved.
azerbajdzan's user avatar
  • 13.5k
6 votes
Accepted

How to indicate table continuation in the middle with torn edge paper effect or something similar

It is not ultra-realistic but ... ...
Syed's user avatar
  • 48.8k
3 votes

How to indicate table continuation in the middle with torn edge paper effect or something similar

...
kglr's user avatar
  • 392k
6 votes

How to indicate table continuation in the middle with torn edge paper effect or something similar

...
kglr's user avatar
  • 392k
3 votes

How to indicate table continuation in the middle with torn edge paper effect or something similar

One possibility code ...
Nasser's user avatar
  • 142k
1 vote

Replacing the Zeros of One List by the (i-1)th Element of Another List

l1 = {0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0}; l2 = {6, 1, 4, 7, 2, 9, 10, 8, 11, 3, 5, 0, 12}; Using MapThread as follows: <...
E. Chan-López's user avatar
1 vote

Replacing the Zeros of One List by the (i-1)th Element of Another List

a = {0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0}; b = {6, 1, 4, 7, 2, 9, 10, 8, 11, 3, 5, 0, 12}; Pre-define positions for better readability ...
eldo's user avatar
  • 61.3k

Top 50 recent answers are included