while-loop

while loop not running until meeting completion condition

天涯浪子 提交于 2019-12-13 20:25:56
问题 I have created a while loop which can't seem to run properly. it calls a method from another class which helps change the stop condition for my program. It calls the method about 3 - 8 times on average and never reaches the stopping condition, however it stops. public class useExample { public static void main(String[] args) { Example ex = new Example(); long [] result; long a = 0; long b = 0; long c = 0; long d = 0; long e = 0; int count = 0; int a1 = 1; int b1 = 2; int c1 = 3; int d1 = 4;

how to identify locations from text

有些话、适合烂在心里 提交于 2019-12-13 20:10:31
问题 Here is sample to my function that getscodes df= read.csv("secondary.csv",header = TRUE) 回答1: S <- "s / O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001" I recommend making all possible N-x strings where N is length of your string and x is variable length allchr <- unlist(strsplit(S, "")) listsubstr <- sapply(1:length(allchr), function(I) paste0(allchr[I:length(allchr)], collapse="")) # [1] "s / O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI

Python - Store function in variable

不羁岁月 提交于 2019-12-13 19:05:39
问题 I have a concept where I store function in variables which makes it easier for me. But I am having the problem that the value in the variable isn't dynamically calling the function each time. So it returns the same value all the time. Just to make clear of the problem, I have made a code snip to illustrate it in a easy way: def value(): resp = requests.get('http://www.google.com').elapsed.total_seconds() return resp test = value() while True: print test time.sleep(10) Output: 0.00649 0.00649

Wiring a while loop with a continue option in java

那年仲夏 提交于 2019-12-13 18:00:55
问题 I am working on a loan calculator with data validation. I have written everything and good to go. The only thing I cannot figure out is how to write a while loop in where the user is asked "Continue y/n?: " and then have the program continue ONLY when the user types y/Y and the program ENDS ONLY when the user types n/N, any other input should give an error message like "Invalid, you can only enter Y or N". So if the user enters "x" it should display the error message. I have tried else if

While command in bash “if there's a $string in file.txt… do…”

喜欢而已 提交于 2019-12-13 17:24:49
问题 Need help with the while command. I want to run a command if there's a $sitename in playlist.txt Here's my bash: cat playlist.txt | grep -e "$sitename" | sed -e "s/^.*\(http:.*"$sitename".*flv\).*$/\1/g" | sort | uniq > checklist.txt cat checklist.txt while [ " While can find $sitename in checklist.txt" ]; do qa done that's what i have tried already while [ -n "$echopl" ]; do qa done while [ 'grep -q $string checklist.txt >/dev/null' ]; do qa done while [ "grep -q "$string" checklist.txt" ];

Loop/Nested Loop problems Python 2.7

点点圈 提交于 2019-12-13 17:23:02
问题 I want the program to ask each of the five players the seven questions, calculate the player score and then display a list of each players score eg Points for week 1 player1 43 player2 26 player3 38 etc etc Then ask the players the questions again and do the same for week 2. Currently the program will only display the first players score, then ask the questions to all five players again but only display the second players score, it repeats this five times while only iterating through the

How to make looped function calls for pagination?

泄露秘密 提交于 2019-12-13 17:12:25
问题 I am attempting to use the Airtable API to retrieve records from my data there - specifically, a list of URLs I have in column cells. I wrote a function, get_airtable_records , to do the API call via curl and it works - returning results as a Json object. Specifically, I am pushing the URLs to an array, $article_urls . The only problem is, Airtable limits the return of results to "pages" of a maximum 100 records, and my data contains more than that. The API accepts parameters maxRecords and

Multiple embedded loops in NodeJS

我的未来我决定 提交于 2019-12-13 16:12:01
问题 I like to execute the following code...but as you can see - it will require 10 billion loops! So i was wondering - what you guys would suggest to make it spin faster? The reason why - i need to like "brute force" to the best result - is because the most inner method do some complex calculation of some historical data - about 7 million rows from a DB...and the point by doing all this - is to find the best "setting" of the given parameters a-f...which gives the best result... var a = 0.1; while

WHILE syntax-error in MySQL

吃可爱长大的小学妹 提交于 2019-12-13 16:06:55
问题 I'm trying to use a while loop in a one-off query on a MySQL ( 5.1.41-3ubuntu12.10-log ) database: WHILE ((SELECT COUNT(*) FROM (SELECT id, COUNT(*) AS cnt FROM foo GROUP BY id ORDER BY COUNT(*) DESC) cnts WHERE cnt > 1) != 0) DO BEGIN SET @curr_id = (SELECT id FROM (SELECT id, COUNT(*) AS cnt FROM foo GROUP BY id ORDER BY COUNT(*) DESC) cnts WHERE cnt > 1 LIMIT 1); SET @new_id = (SELECT MAX(id) + 1 FROM foo); UPDATE foo SET id = @new_id WHERE id = @curr_id LIMIT 1; END WHILE; What this does

Recording voice in a while loop using Tkinter

早过忘川 提交于 2019-12-13 15:21:45
问题 I'm coding a voice recording application and I want to start the recording when the user pushes a Button in Tkinter, and stop the recording when the user releases the Button. import Tkinter def record(): while True Recordning runtines... if <button is released> stop audio steam... break main = Tkinter.Tk() b = Tkinter.Button(main, text='rec', command=record) b.place(x="10", y="10") main.mainloop() How do I achieve the "if button is released"? Do I need to use Threading? 回答1: If you don't want