Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -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.

View 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.

View file

@ -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

View 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)

View 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')
);

View file

@ -0,0 +1,6 @@
1
2
3
4
5
6

View 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')
);

View file

@ -0,0 +1,5 @@
1
2
3
4
5

View file

@ -0,0 +1,8 @@
i = 0
while true
println(i)
i += 1
if i%6 == 0
break
end
end

View file

@ -0,0 +1,8 @@
let mut x = 0;
loop {
x += 1;
println!("{}", x);
if x % 6 == 0 { break; }
}

View 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")