do-loops Questions

4

Solved

I am trying to get make a random number generator that generates a string of numbers between 1 and 9, and if it generates an 8, it should display the 8 last and then stop generating. So far it pr...
Prieto asked 17/8, 2017 at 13:15

3

Solved

I was surprised that you cannot put a array member as the control variable of do loop like this: program test integer, dimension(2) :: i do i(1) = 1, 3 do i(2) = 1, 3 ! anything here write(...
Arbitress asked 28/10, 2014 at 6:50

6

Solved

According to the perl manual for for last (http://perldoc.perl.org/functions/last.html), last can't be used to break out of do {} loops, but it doesn't mention an alternative. The script I'm mainta...
Unheard asked 6/12, 2010 at 18:13

2

Solved

I want to loop over N iterations, but some of the iterations should be "skipped" under particular conditions. I know I can do it using the goto statement, such as : do i = 1, N if condition(i) ...
Redwing asked 11/5, 2016 at 14:48

2

Solved

How do DO loops work exactly? Let's say you have the following loop: do i=1,10 ...code... end do write(*,*)I why is the printed I 11, and not 10? But when the loop stops due to an if(...
Heredity asked 9/8, 2013 at 12:25

2

What is the difference between CODE SNIPPET 1 and CODE SNIPPET 2? ;CODE SNIPPET 1 (define i 0) (do () ((= i 5)) ; Two sets of parentheses (display i) (set! i (+ i 1))) ;CODE SNIPPET 2 (d...
Vallee asked 7/7, 2010 at 21:57

1

Solved

In Peter Seibel's Practical Common Lisp, he gives this example: (do ((nums nil) (i 1 (1+ i))) ((> i 10) (nreverse nums)) (push i nums)) I can see how it works, using nums inside the loop bu...
Terramycin asked 29/10, 2008 at 19:52
1

© 2022 - 2024 — McMap. All rights reserved.