Have a perl brain-teaser:
my @l = ('a', 'b', 'c');
for (@l) {
my $n = 1;
print shift @l while (@l and $n --> 0);
print "\n";
}
What's it print? Should be a, b, and c, right? But oh wait actually there's a bug somewhere, it only prints a and b. Probably just some stupid off-by-one, should be easy to solve, right?
Ok so mak...
Hello,
I am currently working on a site that is being built on codeigniter, I am currently querying the data at the moment I think there could be possible 3 arrays that could be returned as array each with a varying amount of results, my question I cannot for life of me loop through the array I have at the moment,
my model looks like...
How I can use getchar() in a loop? Now I have...
for (p=0; p<n_players; p++) {
...
fflush(stdin);
getchar();
}
But it doesn't work... if n_players is 3, it execute getchar 2 times only at the end...
for (p=0; p<n_players; p++) {
blank_start();
ascii_art_title();
printf("%s, tocca a te...\n",player_info[p].play...
I have a do while that looks like:
User user = userDao.Get(1);
do
{
// processing
// get the next user
//
user = UserDao.GetNext(user.Id);
if(user == null)
continue; // will this work?????????????
}
while ( user != null)
If it does work, its going to go to the top of the do statement, and user is null so things are g...
% calculates the population of a city from year 2000 to 2020
var popstart : int := 80000
var popgrowth : real
var popend : real
var growthrate : real := 0.03
% popgrowth := popstart * growthrate
for i : 2000..2020 by 1
popgrowth := popstart * growthrate
end for
put "year population"
put "==== =========="
put i, " ", popgrowth
...
I need to combine two foreach statement into one for example
foreach ($categories_stack as $category)
foreach ($page_name as $value)
I need to add these into the same foreach statement
Is this possible if so how?
thanks
...
Hi,
I have a simple code that looks up a text file, reads the line of text, splits the string by semi-colons and then posts the results.
After it has done this, I have created a really simple while loop to waste 10 seconds before going for it again.... here is the code:
Private Sub checkTemps()
While Abort = False
Try
...
Hi all, i looking for help... and hope of you kindly
I want to change my site language model from radio button to auto dropdown button using loop
This the languages
if ($lang=="en") {
//Pages
define ("Pages", "Pages") ;
}
if ($lang=="de") {
define ("Pages", "Seiten") ;
}
This the existing Radio button
<td width="6...
OK I am looping through the properties in an object like so:
private var _propsList:Object = {'Type':'product_type'
,'Kind':'product_type_sub'
,'Stone':'primary_stone'
,'Stone Color':'primary_stone_sub'
,'Metal':'metal_type'
...
Okay, so I've got a piece of Python code which really needs optimizing.
I need to iterate over every single pixel of a small (80x60) image and extract the RGB values from it. The code in the loop itself isn't too slow, but I'm doing it using nested for loops, which I assume add quite a bit of overhead...
xr = xrange(80)
yr = xrange(60)...
Dear Colleagues
I am a newie in Ruby and I am facing a problem regarding "each"-like loops. Suppose a code like the following
startIndex = 1
endIndex = 200
(startIndex..endIndex).each do |value|
p value
if value>150 then endIndex=100
end
When I run the code it will run until 200, not until 150. Is there any way to change the l...
Hi all,
PLATFORM:
PHP, mySQL
WHAT I HAVE:
I have a Database table. Within my application, I am able to fetch all the rows. When I am querying the database, I have set the records fetch limit dynamically.
WHAT I AM TRYING TO DO:
I am trying to pull out all the rows of data until the record fetch limit is reached, in a loop. I want...
Here's my issue. I have this function to test proxy servers.
function crawl() {
var oldstatus = document.getElementById('status').innerHTML;
document.getElementById('status').innerHTML = oldstatus + "Crawler Started...<br />";
var url = document.getElementById('url').value;
var proxys = document.getElementById('proxys')....
We have a project that needs to gather survey data. On one particular page of the website, there are 21 questions each with a scale of 1-5 where the user selects one radio button for each question in the table.
The survey is being coded in VB.NET. The data submits to an SQL database. All the radio buttons are similarly named, so only th...
i have the following JSON response, but i am not sure how to properly loop trough it and use.
{
"ID": 1,
"Name": "dept1",
"Categories": [
{
"ID": 1,
"Name": "catg1"
},
{
"ID": 2,
"Name": "catg2"
}
]
}
following code alerts me the departmentID which is 1, then its name 'dept1', then this:...
Is there a way to print numbers from 1 to 100 without using any loops or conditions like "if"?
We can easily do using recursion but that again has an if condition. Is there a way to do without using "if" as well? Also no repetitive print statements,or a single print statement containing all the numbers from 1 to 100.
A solution in Java ...
Using jQuery I would like to loop through an array of links and load the contents of each link into a DIV after a set interval. For example, if I have my parent page "parent.html" and an array of links - "test1.html, test2.html and test3.html" I would like to initially load test1.html into a div within parent.html and then after a set in...
Will the strlen() function below get called just once (with the value stored for further comparisons); or is it going to be called every time the comparison is performed?
for (i = 0; i < strlen(word); i++)
{ /* do stuff */ }
...
I have the following function but despite using the break statement, it doesn't seem to be stopping after it finds a match in the array:
private function CheckMatch() {
// _playersList is the Array that is being looped through to find a match
var i:int;
var j:int;
for (i= 0; i < _playersList.length...
I can't seem to figure out why this is an infinite loop in python??
for i in range(n):
j=1
while((i*j)<n):
j+=1
shouldn't the outer loop go n times. incrementing j until its equal to n div i each time?
...