June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -2,5 +2,23 @@ Start with a value at 0. Loop while value mod 6 is not equal to 0.
|
|||
Each time through the loop, add 1 to the value then print it.
|
||||
The loop must execute at least once.
|
||||
|
||||
|
||||
;Related tasks:
|
||||
* [[Loop over multiple arrays simultaneously]]
|
||||
* [[Loops/Break]]
|
||||
* [[Loops/Continue]]
|
||||
* [[Loops/Do-while]]
|
||||
* [[Loops/Downward for]]
|
||||
* [[Loops/For]]
|
||||
* [[Loops/For with a specified step]]
|
||||
* [[Loops/Foreach]]
|
||||
* [[Loops/Increment loop index within loop body]]
|
||||
* [[Loops/Infinite]]
|
||||
* [[Loops/N plus one half]]
|
||||
* [[Loops/Nested]]
|
||||
* [[Loops/While]]
|
||||
|
||||
|
||||
;Reference:
|
||||
* [[wp:Do while loop|Do while loop]] Wikipedia.
|
||||
<br><br>
|
||||
|
|
|
|||
15
Task/Loops-Do-while/Fortress/loops-do-while.fortress
Normal file
15
Task/Loops-Do-while/Fortress/loops-do-while.fortress
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
component loops_do_while
|
||||
export Executable
|
||||
|
||||
var x:ZZ32 = 0
|
||||
run() = label loop
|
||||
while true do
|
||||
x += 1
|
||||
println(x)
|
||||
|
||||
if (x MOD 6) = 0
|
||||
then exit loop
|
||||
end
|
||||
end
|
||||
end loop
|
||||
end
|
||||
8
Task/Loops-Do-while/GW-BASIC/loops-do-while-1.gw-basic
Normal file
8
Task/Loops-Do-while/GW-BASIC/loops-do-while-1.gw-basic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
10 LET I% = 0
|
||||
20 ' first iteration - before the WHILE
|
||||
30 PRINT I%
|
||||
40 LET I% = I% + 1
|
||||
50 WHILE I% MOD 6 <> 0
|
||||
60 PRINT I%
|
||||
70 LET I% = I% + 1
|
||||
80 WEND
|
||||
4
Task/Loops-Do-while/GW-BASIC/loops-do-while-2.gw-basic
Normal file
4
Task/Loops-Do-while/GW-BASIC/loops-do-while-2.gw-basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
10 LET I% = 0
|
||||
20 PRINT I%
|
||||
30 LET I% = I% + 1
|
||||
40 IF I% MOD 6 <> 0 THEN GOTO 20
|
||||
10
Task/Loops-Do-while/Haskell/loops-do-while-4.hs
Normal file
10
Task/Loops-Do-while/Haskell/loops-do-while-4.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import Data.IORef
|
||||
import Control.Monad.Loops
|
||||
|
||||
main = do
|
||||
x <- newIORef 0;
|
||||
iterateWhile (\val -> val `mod` 6 /= 0 ) $ do
|
||||
modifyIORef x (+1)
|
||||
val <- readIORef x
|
||||
print val
|
||||
return val
|
||||
20
Task/Loops-Do-while/JavaScript/loops-do-while-8.js
Normal file
20
Task/Loops-Do-while/JavaScript/loops-do-while-8.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// generator with the do while loop
|
||||
function* getValue(stop) {
|
||||
var i = 0;
|
||||
do {
|
||||
yield ++i;
|
||||
} while (i % stop != 0);
|
||||
}
|
||||
|
||||
// function to print the value and invoke next
|
||||
function printVal(g, v) {
|
||||
if (!v.done) {
|
||||
console.log(v.value);
|
||||
setImmediate(printVal, g, g.next());
|
||||
}
|
||||
}
|
||||
|
||||
(() => {
|
||||
var gen = getValue(6);
|
||||
printVal(gen, gen.next());
|
||||
})();
|
||||
6
Task/Loops-Do-while/JavaScript/loops-do-while-9.js
Normal file
6
Task/Loops-Do-while/JavaScript/loops-do-while-9.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
template doWhile(a: expr, b: stmt): stmt =
|
||||
template doWhile(a, b: untyped): untyped =
|
||||
b
|
||||
while a:
|
||||
b
|
||||
|
|
|
|||
7
Task/Loops-Do-while/Red/loops-do-while.red
Normal file
7
Task/Loops-Do-while/Red/loops-do-while.red
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Red []
|
||||
i: 0
|
||||
until [
|
||||
?? i
|
||||
i: i + 1
|
||||
i % 6 = 0 ;; loop , until this is true...
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue