Skip to main content

Questions tagged [loops]

A **loop** is a sequence of statements which is specified once but which may be carried out several times in succession.

1 vote
1 answer
216 views

Suppose I need to find the last selected index of options according to last selected contents, eg: options : A,B,C,D,E ,last selected option: C, so the last selected index is 2. There is a special ...
wcminipgasker2023's user avatar
3 votes
4 answers
480 views

I have a function (written in Python) that processes a loosely structured log file. The log file would have begin-end markers for different sections, with each section describing different things (e.g....
Happy Green Kid Naps's user avatar
-3 votes
1 answer
91 views

I'm currently in the process of reworking a monolithic function. My first step is finding blocks of code that can be extracted into their own "sub"-methods for ease of readability & ...
Incubbus's user avatar
2 votes
2 answers
165 views

I would like to explain the following code to my colleagues: for options in [{Option.NO_CUTOFFS}, {}, {Option.HEURISTIC}]: ... The following sentence is kind of awkward: This loop loops on the ...
AlwaysLearning's user avatar
-1 votes
2 answers
5k views

When processing data sets in batches I usually can think of the following three implementations. Which one do you consider better than the other and why? Notes: The implementation is in C# but the ...
Botond Botos's user avatar
1 vote
2 answers
259 views

I have a Node.js micro-service architecture-based back-end. Services communicate with each other via PubSub. E.g. upon a request to service A, service A messages either service B or service C via ...
cis's user avatar
  • 255
4 votes
2 answers
169 views

Often I need to get some data and process it in some way. For example getting a list of customers from an API and assemble some summary data on them. As an example, getting : api_result = api.request(...
User's user avatar
  • 1,581
0 votes
1 answer
99 views

Consider the following pseudo-code: cont = 0 for g = 1,...,m for h = g,...,m cont = cont + 1 end for end for I'm searching for the explicit map that returns cont in ...
Gost91's user avatar
  • 111
-5 votes
1 answer
1k views

If I have code that looks like this: int i; void functionA (){ for (i=0; i<10; i++){ functionB(); } } void functionB (){ for (i=0; i<20; i++){ doSomething(); } } ...
Noah Smith's user avatar
1 vote
2 answers
1k views

I'm confused about a matter that I've been unable to figure out. I'm doing some leetcode problems. In backtracking problems, sometimes we use loop within our recursive method to call the recursion but ...
Umer Farooq's user avatar
24 votes
9 answers
9k views

If I have a function that never returns (it contains an infinite loop) how do I declare/communicate that it will never return to the user of the function? The user does not see the source code, only ...
Fred's user avatar
  • 509
0 votes
5 answers
602 views

Let me explain what I mean. Imagine A subs to event b. In such case A pubs event a. B subs to event a. In this case B subs b. This is a full-blown circle. How does a pub/sub cycle deal with such ...
Aurlito's user avatar
  • 27
3 votes
1 answer
434 views

Recently I was asked to refactor some code that leverages JavaScript's array.reduce() method because other developers felt the code hard to read. While doing this I decided to play around with some ...
Kenneth Moore's user avatar
-4 votes
4 answers
776 views

I don't think any of them are good practice. In addition to that they make the code longer. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for Optional initialization ...
thadeuszlay's user avatar
-4 votes
1 answer
166 views

I am modifying a software which is for trash collection. While reading the code, I asked myself is there any formula or trick to quickly calculate the number of time the statement gets executed inside ...
AKdeBerg's user avatar

15 30 50 per page
1
2 3 4 5
11