Tagged Questions

A loop is a series of statements which may be carried out several times in succession. The code that makes up the loop is executed a specific number of times, or until some condition is met.

learn more… | top users | synonyms

0
votes
0answers
36 views

Java - Object declaration out of while loop

Could you explain to me which code is better (more optimal) and why? Vesion 1: while(something){ Runnable task = (Runnable) taskQueue.dequeue(); Throwable ex = null; ... } Version 2: Runnable ...
1
vote
1answer
37 views

Downsampling boundaries of a 2D array

I have a linearized 2D array u (block_height * block_width) containing the values of a physical quantity over a regular 2D mesh. I need to downsample boundaries (top, bottom, left, right) of this ...
1
vote
1answer
89 views

!empty() check before a foreach statement

Is this the best way to prevent that foreach loop from happening if $terms doesn't exist? $terms = get_the_terms( $postid, 'fecha' ); if(!empty($terms)) { foreach($terms as $term) { ...
1
vote
0answers
34 views

Datagrid not refreshing correctly with Async Ping VB .Net

I have an application coded in VB.NET that has a bunch of servers in a DataGridView and does a continuous asynchronous ping. If all the servers are up it refreshes great, but if one goes down and ...
-1
votes
0answers
66 views

ping multiple IP's from Datagridview C# [closed]

I need to make a program that uses Asynchronous pings to cycle through a datagridview that has a list of server names or IP Addresses and ping them at the same time. and return the values to the ...
1
vote
2answers
106 views

Is it possible to simplify this code?

I can't get my head around this easy step-by-step validation. I already had it in a while-loop, but found it even more horrible than with beginner-like if-cases. I still think though, that it could be ...
2
votes
0answers
77 views

Better method to loop through arrays in VBA

I supplied the following code as an answer to this question on SO, but I was wondering if there was a better way to write out all those array loops. (i.e. perhaps using a Collection/Dictionary?) It ...
2
votes
1answer
51 views

An in-nested sequence generator for racket scheme

I've been learning about racket sequences and noticed a hole where nested iteration is concerned. We have the in-parallel construct but no in-nested construct. There's the for*/... family, but ...
1
vote
3answers
126 views

Optimize Array.indexOf

How can I optimize checking a value in recursion before operating on it? I'm using Array.indexOf (this is Javascript) var nums = [], lengths = []; function findNumLength(n) { //preliminary check ...
1
vote
2answers
105 views

Better way to structure this PHP loop code?

As you can see from the code below, my set function accepts two types of parameters: either strings or arrays. Now, ideally I would like to be using operator overloading to handle this, but since PHP ...
1
vote
2answers
46 views

Refactoring 3 level depth for loops in JavaScript

I'm trying to get rid of some of the horrible nested loops in the following code. Essentially is moving TDs to top rows based on whether the current row has the current cell. You can see the ...
4
votes
2answers
234 views

Optimisations for this loop? (Garbage collection is slowing it down)

I'm working on a Game Of Life clone as my first project. I'm still relatively new to programming, so my code is probably not really optimised. The biggest bottleneck is in my Start() method, but that ...
3
votes
1answer
146 views

Writing to an HttpURLConnection in a loop

I have this method which sends binary data to server. The code works fine, but still, it's structure is kinda stupid: output and input connections are opened like thousands times (depends on data ...
2
votes
1answer
87 views

Improve grouping in LINQ

I have a collection (Child Collection) on which I am performing some operation to make another collection (Parent Collection). But that I do in a dirty foreach loop. I want to do it in an elegant way. ...
3
votes
2answers
170 views

I want to create a photo changer loop in python. Can someone check my code?

I just started python a few days ago, and I haven't programmed much before. I know my code is terrible; however, I would like someone to look it over. What I'm trying to do is create a photo "loop" ...

1 2 3
15 30 50 per page