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(...
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) ...
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(...
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...
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...
1
© 2022 - 2024 — McMap. All rights reserved.