Questions tagged [procedural-programming]
Questions about Mathematica's procedural programming paradigm.
361 questions
0
votes
0
answers
54
views
3
votes
3
answers
506
views
Using Out (%) with control flow
I make heavy use of Out in Mathematica's notebook environment. When I get a computation to work, it will often be spread across multiple cells and lines with ...
1
vote
3
answers
229
views
Faster way to apply a list of numbers to a list of functions
I'm trying to apply two lists random numbers to a list of lists of functions, retrieve a Boolean result for each application, and test for AND coincidence between results. I have a working method, ...
1
vote
3
answers
255
views
What is the simplest way to write a GeneralizedDo function?
A GeneralizedDo is supposed to thread over multiple iterators:
...
6
votes
7
answers
557
views
Loop over array cyclically
Is there any way to make cyclic loop over array without PadLeft,PadRight, ArrayPad?
So ...
4
votes
1
answer
216
views
Optimizing Iterative Computations with Large Ranges in Mathematica
I have an implementation in Mathematica that involves iteratively generating large ranges of values, performing element-wise operations, and calculating a cumulative product followed by a total. While ...
0
votes
0
answers
166
views
Optimizing a While Loop for High-Precision Computation in Mathematica
Edit: Clarifying the Core Issue
i=x;
While[Abs[p1 - p2] >= p1 tol,
p2 = p1;
p1 += s *= i (mkn + i)/((k1 - i) (n1 - i));
i--;
];
The core of my ...
1
vote
1
answer
154
views
Translating Python for loops to Mathematica [closed]
I have the following snippet written in Python that I want to run in Mathematica
...
1
vote
1
answer
162
views
Efficiently collecting results from nested loops
My question involves what is often considered to be horrible Mathematica code; that is, code which is essentially procedural involving nested loops, rather than mapping, threading, and so forth. Here, ...
1
vote
0
answers
129
views
Import and assign/manipulate the content of a huge number of files efficiently
I have a folder containing eg. around 40K txt files with randomly assigned names.
I am trying to import the content of these files as List/Table and process them ...
3
votes
0
answers
96
views
Return and Function [duplicate]
Can somebody explain the behavior of Return inside a function? I know that Function and If ...
0
votes
0
answers
73
views
Checking whether a linear homogeneous system with m equations and n>m unknowns, has m unknowns that are sums with positive coefficients of the others
I call a "pseudo-linear", homogeneous system with m equations positively representable, if it has m terms that are sums with positive coefficients of the others. A class with precisely one &...
1
vote
1
answer
127
views
Make a loop while graph is not empty
I'm new to Mathematica and I'm attempting to write an approximation algorithm to compute "maximum" independent sets. What I need to do is given a graph g ...
1
vote
2
answers
188
views
RecurrenceTable vs For loop : they do not give the same results. Why?
I have a second-order recurrence equation that I want to plot.
I've used two different methods.
The first uses RecurrenceTable, the second uses a traditional ...
0
votes
1
answer
134
views
How can I transpose SCILAB/MATLAB code with for loop into Mathematica? [closed]
How can I transpose the following SCILAB/MATLAB code into MATHEMATICA?
I took a look at similar questions, but none of them seemed to provide a solution.
...