Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,3 +1,6 @@
|
|||
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.
|
||||
|
||||
;Reference:
|
||||
* [[wp:Do while loop|Do while loop]] Wikipedia.
|
||||
|
|
|
|||
11
Task/Loops-Do-while/ALGOL-W/loops-do-while.alg
Normal file
11
Task/Loops-Do-while/ALGOL-W/loops-do-while.alg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
begin
|
||||
integer i;
|
||||
i := 0;
|
||||
while
|
||||
begin
|
||||
i := i + 1;
|
||||
write( i );
|
||||
( i rem 6 ) not = 0
|
||||
end
|
||||
do begin end
|
||||
end.
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
open console
|
||||
open monad io
|
||||
|
||||
loop n | n % 6 == 0 = out ()
|
||||
| else = out `seq` loop (n+1)
|
||||
where out = & writen n
|
||||
loop n | n % 6 == 0 = do return ()
|
||||
| else = do
|
||||
putStrLn (show n)
|
||||
loop (n+1)
|
||||
|
||||
_ = loop 10 ::: IO
|
||||
|
|
|
|||
10
Task/Loops-Do-while/Elixir/loops-do-while.elixir
Normal file
10
Task/Loops-Do-while/Elixir/loops-do-while.elixir
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
defmodule Loops do
|
||||
def do_while(n) do
|
||||
n1 = n + 1
|
||||
IO.puts n1
|
||||
if rem(n1, 6) == 0, do: :ok,
|
||||
else: do_while(n1)
|
||||
end
|
||||
end
|
||||
|
||||
Loops.do_while(0)
|
||||
19
Task/Loops-Do-while/JavaScript/loops-do-while-2.js
Normal file
19
Task/Loops-Do-while/JavaScript/loops-do-while-2.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function doWhile(varValue, fnBody, fnTest) {
|
||||
'use strict';
|
||||
var d = fnBody(varValue); // a transformed value
|
||||
|
||||
return fnTest(d) ? [d].concat(
|
||||
doWhile(d, fnBody, fnTest)
|
||||
) : [d];
|
||||
}
|
||||
|
||||
console.log(
|
||||
doWhile(0, // initial value
|
||||
function (x) { // Do body, returning transformed value
|
||||
return x + 1;
|
||||
},
|
||||
function (x) { // While condition
|
||||
return x % 6;
|
||||
}
|
||||
).join('\n')
|
||||
);
|
||||
6
Task/Loops-Do-while/JavaScript/loops-do-while-3.js
Normal file
6
Task/Loops-Do-while/JavaScript/loops-do-while-3.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
28
Task/Loops-Do-while/JavaScript/loops-do-while-4.js
Normal file
28
Task/Loops-Do-while/JavaScript/loops-do-while-4.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
function range(m, n) {
|
||||
'use strict';
|
||||
return Array.apply(null, Array(n - m + 1)).map(
|
||||
function (x, i) {
|
||||
return m + i;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function takeWhile(lst, fnTest) {
|
||||
'use strict';
|
||||
var varHead = lst.length ? lst[0] : null;
|
||||
|
||||
return varHead ? (
|
||||
fnTest(varHead) ? [varHead].concat(
|
||||
takeWhile(lst.slice(1), fnTest)
|
||||
) : []
|
||||
) : []
|
||||
}
|
||||
|
||||
console.log(
|
||||
takeWhile(
|
||||
range(1, 100),
|
||||
function (x) {
|
||||
return x % 6;
|
||||
}
|
||||
).join('\n')
|
||||
);
|
||||
5
Task/Loops-Do-while/JavaScript/loops-do-while-5.js
Normal file
5
Task/Loops-Do-while/JavaScript/loops-do-while-5.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
8
Task/Loops-Do-while/Julia/loops-do-while.julia
Normal file
8
Task/Loops-Do-while/Julia/loops-do-while.julia
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
i = 0
|
||||
while true
|
||||
println(i)
|
||||
i += 1
|
||||
if i%6 == 0
|
||||
break
|
||||
end
|
||||
end
|
||||
8
Task/Loops-Do-while/Rust/loops-do-while.rust
Normal file
8
Task/Loops-Do-while/Rust/loops-do-while.rust
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
let mut x = 0;
|
||||
|
||||
loop {
|
||||
x += 1;
|
||||
println!("{}", x);
|
||||
|
||||
if x % 6 == 0 { break; }
|
||||
}
|
||||
7
Task/Loops-Do-while/Scilab/loops-do-while.scilab
Normal file
7
Task/Loops-Do-while/Scilab/loops-do-while.scilab
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
v=0
|
||||
while %T
|
||||
v=v+1
|
||||
printf("%2d ",v)
|
||||
if modulo(v,6)==0 then break; end
|
||||
end
|
||||
printf("\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue