while-loop

input sequential numbers without specific end in a data frame's column in r

南笙酒味 提交于 2020-01-06 07:09:10
问题 I would like to give a sequence of numbers to a new column to a data frame. But this sequence will repeat several times based on a value in another column. (i.e It starts from 1 until that specific value will be changed to other value). My problem is how to define the ending point for each sequence in r. A part of my data frame with the column "V2" which I intend to add: V1 V2(new added column with sequential numbers) 12 1 12 2 12 3 12 4 12 5 13 1 13 2 13 3 13 4 13 5 13 6 14 1 14 2 14 3 14 4

While loop is taking too much time to execute, also within the loop elapsed time is large

纵然是瞬间 提交于 2020-01-06 06:02:14
问题 I’m working on a radar project using USRP N210 with UBX-40 daughterboard using MATLAB. I am facing a problem when I run the code for receiving the echo of the transmitted pulse. It is taking 4 seconds for the board to start receiving and collecting first sample, which doesn’t suit at all my case. After the first sample, receiving elapsed time for the other echoes is in milliseconds which not good because, echoes in radars should be received within microseconds or less and not seconds and

Strange python while loop behavior with < comparison

随声附和 提交于 2020-01-06 02:41:46
问题 I'm confused with this snippet of code: t=0 while t<5: #currently loop runs for 10 seconds print "in loop",t if (t<5): print "true" t=t+0.01 prints in the last run through of the loop: in loop 5.0 true Now if it is true that t = 5.0 on the last pass through the loop, shouldn't the condition that t < 5 in the if statement not be met? And furthermore, shouldn't it not even be running through the loop for t=5 since it should have also failed the while condition? 回答1: 5 isn't necessarily 5: t=0

Stop loop when condition variable (global var) changes in javascript

孤人 提交于 2020-01-06 01:32:11
问题 I'm having a problem that I can't solve. I have a loop in javascript where the condition variable to stop depends on a global variable. The loop starts looping and when I change the value of that global variable it never stops. stop = false; var i = 0; while ((stop == false) && (i<100000)){ console.log("hi-"+i); i++; } While loop is running, if I do stop = true, it never stops. I do not know why is that. Any idea? Thanks! 回答1: JavaScript is inherently single threaded. Once a block of code has

Creating a function that deletes a certain character from a string. What is wrong with my program?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 08:36:58
问题 I am trying to delete all G's from a string. I need to use a pointer, but my problem is I don't know what to replace the found G's with. I did not know an empty character constant ('') would not compile. How can I remove the character keeping in line with this code? void deleteG(char cString[]) { char *ptr; ptr = cString; while (*ptr != '\0') { if (*ptr == 'g' || *ptr == 'G') { *ptr = ' '; } ptr++; } } 回答1: I'd recommend something like this... void deleteAlpha(char cString[]) { const char

Can anyone spot why my Wordpress loop breaks all the Advanced Custom Fields code that comes after it?

£可爱£侵袭症+ 提交于 2020-01-05 07:29:16
问题 The following loop is running successfully and shows no syntax error in my editor, but it's breaking only the Advanced Custom Fields PHP that comes after it (all the ACF before it works fine, and everything after except ACF works fine). <?php $args=array( 'post_type' => 'page', 'post_parent' => '39' ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <div class="project" style="background-image:url('<?php the_field(

How to run an infinite while loop in pygtk?

☆樱花仙子☆ 提交于 2020-01-05 07:01:20
问题 I am creating an application in pygtk which involves running an infinite loop. The loop, I think, interferes witk gtk.main() and hence the application does not respond. Actually, I am building a server-type application which continuously listens for client connections.Plzzz help....I am a newbie in this. This is a sample of what I was initially trying to do.(For those who wanted the code) while 1: s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('',2727)) s.listen(1) c,d=s.accept()

How to run an infinite while loop in pygtk?

梦想的初衷 提交于 2020-01-05 07:01:09
问题 I am creating an application in pygtk which involves running an infinite loop. The loop, I think, interferes witk gtk.main() and hence the application does not respond. Actually, I am building a server-type application which continuously listens for client connections.Plzzz help....I am a newbie in this. This is a sample of what I was initially trying to do.(For those who wanted the code) while 1: s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('',2727)) s.listen(1) c,d=s.accept()

PHP double while loop, second loop not iterating more than once

夙愿已清 提交于 2020-01-05 04:14:27
问题 so I'm working on a "product listing", and the idea is to have the name of the product and then a drop down list of colours derived from the database. The problem is I can only get the "colours" while loop to iterate the once, I get the first product name and the colours in the drop down menu the once but not subsequently, the help I'd like is, how can I change this code to make it do what I need, I've been trying for a week and I could really use some help. $product_query = mysql_query(

While Loop using PHP with a MySQL server

时间秒杀一切 提交于 2020-01-04 21:31:31
问题 I have a database (SQL) with the table "Staff" with two records in it. I am required to display the contents of these records on a web page using PHP. <html> <head> <title>CES Staff details</title> </head> <body> **code emitted** <?php $row = mysql_fetch_array($result) ; $looping = 1; $i = $row.length; while ($looping <= $i) { echo $row["Name"].", Room ".$row["Room"].", Tel ".$row["Telephone"] ; $looping++; } ?> </body> </html> How would I change the while loop correctly so that it will