Questions tagged [do-loops]

a 'do' loop is a specific type of iteration used to run code repeatedly based on the evaluation of a boolean statement or variable.

do (while) loops in Java: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

do loops in Fortran: https://en.wikibooks.org/wiki/Fortran/Fortran_control#Loops

do loops in Scheme: https://schemers.org/Documents/Standards/R5RS/HTML/

389 questions
2
votes
2 answers

Having trouble incrementind and decrementing lives

So I'm trying to add lives in my game on Android, and when I run my if else block, the lives will only decrement by 1 or add by 1 but won't go any further than just going down or up by one, I need it to go down every time a guess is wrong but it…
2
votes
1 answer

Avoid IF statements in a Fortran DO loops

In my Fortran program I have something similar to this do loop do i = 1,imax if(period) then call g_period() else call g() endif enddo I have this several places and sometimes several If loops within a do loop which…
ATK
  • 1,296
  • 10
  • 26
2
votes
2 answers

Eliminating/Altering a loop to speed up code

I have some VBA code written that runs quite slowly. I have a series of different loops in my code. I know that loops aren't always the most efficient way to manipulate data, so I think they are the problem. I need ideas for how to either alter the…
DiYage
  • 33
  • 4
2
votes
1 answer

Why the outputs are strange when using REAL type values as do-loop control variables in Fortran?

When I code in Fortran language, I find when I set REAL value as control-var in do-loop, the outputs are strange, for example: do i=0.1,1.0,0.1 write (13,"(F15.6)") i end do The out puts are: 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0.But when I set…
Wilber
  • 41
  • 1
  • 5
2
votes
1 answer

How to make a vbscript loop in loop go to start of code

When running this code; varCheck=True Do While varCheck Pass=InputBox("Enter Password") Do If IsEmpty(pass) Then WScript.quit Exit Do End If If Pass = "123" Then varCheck=False …
Curious George
  • 71
  • 1
  • 1
  • 9
2
votes
3 answers

fibonacci using mathematica

New to Mathematica, I am trying to print the out the first 50 Fibonacci numbers using a Do loop, but can't seem to make it work. I know there is a built-in function that returns the Fibonacci sequence given a number but I want to implement it using…
itms
  • 183
  • 2
  • 14
2
votes
0 answers

How to create horizontal planes that follow exponential growth function in scheme programming?

I want to create horizontal surfaces along the y-direction that follow the exponential growth function: y = 3.1268*e^(0.7234*x) The program that I use implements scheme language, which I am not much familiar with. The x values change from 1 to 10,…
Emma
  • 149
  • 10
2
votes
1 answer

SAS Do Loop is Omitting Rows in Processing

I have the following code. I am trying to test a paragraph (descr) for a list of keywords (key_words). When I execute this code, the log reads in all the variables for the array, but will only test 2 of the 20,000 rows in the do loop (do i=1 to 100…
2
votes
0 answers

Spark Lines and DO-loops

I have a workbook with several sheets. One of the sheets "Calc" summarizes the data for 8 spark lines I have presented on a summary page based on an employee ID number entered on the summary page. I have a created DO-loop macro to run this summary…
Greg Mason
  • 21
  • 2
2
votes
1 answer

Xcode beta 7 - Do-While loop SWIFT Error

The following code gives the error Expected 'while' in 'do-while' loop if let path = NSBundle.mainBundle().pathForResource("Chapters", ofType: "txt"){ do { let stringFromFile = try String(contentsOfFile:path, encoding: NSUTF8StringEncoding) …
ScarletEnvy
  • 871
  • 1
  • 7
  • 14
2
votes
1 answer

Converting a Go-to statement from FORTRAN 77 to Fortran 90

I am working on a piece of legacy F77 code and trying to convert it to equivalent F90 code. I ran into these lines below and could some one advise if my conversion is correct? Fortran 77 code: Subroutine area(x,y,z,d) do 15 j=1,10 if (a.gt.b)…
2
votes
3 answers

When the output statement is specified in the SAS Do loop, why does the stored value for index variable differ?

In the data set Work.Invest, what would be the stored value for Year? data work.invest; do year=1990 to 2004; capital+5000; capital+(capital*.10); end; run; a. missing b. 1990 c. 2004 d. 2005 The correct ans given in…
2
votes
1 answer

do while loop design has design issue

For my method, partition, for my quick sort, it is okay when I run it. However, whenever I upload on the project submit page, the testing returns negative result for the design of this code. which is like static long partition(DataArray array, long…
Jieun Chon
  • 139
  • 1
  • 10
2
votes
1 answer

SAS array DO loop calculation within data step

I have the following data set: data have; input x10 x22 x13 x64; cards; 20 10 30 1 ; run; I want to create four new columns called log_x10, log_x22, log_x13, log_x64 which are the logs of the original columns. I know this is probably a fairly…
pyll
  • 1,688
  • 1
  • 26
  • 44
2
votes
2 answers

Why does the Rails form helper look like a do loop?

Here's a question I've been meaning to ask for a long time, but have just accepted it as "Rails magic" up to this point. As the title states, why does the Rails form helper look like a do loop? If you check the official Rails documentation, it…
Kyle Bachan
  • 1,053
  • 2
  • 15
  • 33
1 2
3
25 26