Questions tagged [refactoring]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
7 votes
1 answer
2k views

How to replace a string within a selected region in a notebook?

I want to replace a string in a selected region/cell in mathematica notebook/package. I searched but didn' t get any result. I think it' s a quite common feature for editors/programming environments. ...
xgdgsc's user avatar
  • 237
6 votes
1 answer
2k views

Wolfram Workbench - how to rename local variables

I'm refactoring some old code. I used really short names for local variables, which I'm coming to regret. Is there an easy way to rename local variables in scope using Wolfram workbench? Here is an ...
Ajasja's user avatar
  • 13.7k
4 votes
1 answer
108 views

What is a more expedient way to assign variable names to individual elements in a list?

There is a set of one-dimensional descriptive statistics that I need so often that instead of copying and pasting calculations each time I created a function (...
Jules Manson's user avatar
  • 2,457
2 votes
0 answers
48 views

How to refactor solution verification function for solving simple ordinary differential equations with Dsolve? [closed]

I have tried different approaches but none would work for me as I am new to both functional programming and Mathematica. At bottom is the code I have. How ...
Jules Manson's user avatar
  • 2,457
1 vote
1 answer
117 views

Is there any way to refactor this equation?

I have a function produce this equation: (-4*dt^2*(c3 + a3*t)^2*t0^4 + dxC^2*(t0^2 + t1^2)^2 + dxM^2*(t0^2 + t1^2)^2 + dxY^2*(t0^2 + t1^2)^2)/(4*t0^4) Is there any ...
Quark Soup's user avatar
  • 1,610
1 vote
1 answer
53 views

Variable refactoring and multi-selection

In IDEs like PyCharm for Python, I can select a variable name or method name and it will highlight to show where all I have used it. Also its easy to refactor the names under a given text selection. ...
Rene Duchamp's user avatar
  • 1,419
1 vote
0 answers
78 views

Can one collect with respect to two groups of variables?

Here is a toy example of what I want: given ...
მამუკა ჯიბლაძე's user avatar
1 vote
0 answers
24 views

Rewriting GroupBy[{elem1,elem2,…},spec,red] into GroupBy[spec] , how to apply reduction?

I'm currently using this version of GroupBy: GroupBy[{elem1,elem2,…},spec,red] applies the function red to reduce lists of values that are generated. I want to rewrite my function with this one: ...
J2ghz's user avatar
  • 111
0 votes
2 answers
67 views

Numerical output using Select and FactorInteger

I have concocted a function from other peoples examples to find the powers of two in a prime decompostion, in the example below its $2^2=4$ gives {2,2}. ...
onepound's user avatar
  • 343