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

@ -0,0 +1,32 @@
* Loops/Continue 12/08/2015
LOOPCONT CSECT
USING LOOPCONT,R12
LR R12,R15
BEGIN LA R8,0
SR R5,R5
LA R6,1
LA R7,10
LOOPI BXH R5,R6,ELOOPI for i=1 to 10
LA R3,MVC(R8)
XDECO R5,XDEC
MVC 0(4,R3),XDEC+8
LA R8,4(R8)
LR R10,R5
LA R1,5
SRDA R10,32
DR R10,R1
LTR R10,R10
BNZ COMMA
XPRNT MVC,80
LA R8,0
B NEXTI
COMMA LA R3,MVC(R8)
MVC 0(2,R3),=C', '
LA R8,2(R8)
NEXTI B LOOPI next i
ELOOPI XR R15,R15
BR R14
MVC DC CL80' '
XDEC DS CL16
YREGS
END LOOPCONT

View file

@ -10,8 +10,6 @@ begin
goto Continue;
end if;
Put (",");
-- label must be followed by a statement.
<<Continue>>
null;
<<Continue>> --Ada 2012 no longer requires a statement after the label
end loop;
end Loop_Continue;

View file

@ -1,8 +1,13 @@
open console imperative
open monad io
loop n | n > 10 = ()
| else = rec write (show n) f `seq` loop (n+1)
where f | n % 5 == 0 = "\r\n"
| else = ", "
loop n =
if n > 10 then do
return ()
else do
putStr (show n)
putStr f
loop (n + 1)
where f | n % 5 == 0 = "\r\n"
| else = ", "
loop 1
_ = loop 1 ::: IO

View file

@ -1,8 +1,11 @@
open console imperative
open monad io
loop [] = ()
loop (x::xs) = rec (write << show) x c `seq` loop xs
where c | x % 5 == 0 = "\r\n"
| else = ", "
loop [] = return ()
loop (x::xs) = do
putStr (show x)
putStr f
loop xs
where f | x % 5 == 0 = "\r\n"
| else = ", "
loop [1..10]
_ = loop [1..10] ::: IO

View file

@ -0,0 +1,10 @@
defmodule Loops do
def continue do
Enum.each(1..10, fn i ->
IO.write i
IO.write if rem(i,5)==0, do: "\n", else: ", "
end)
end
end
Loops.continue

View file

@ -4,18 +4,18 @@
main() ->
for_loop(1).
for_loop(N) when N /= 5 , N <10 ->
for_loop(N) when N /= 5 , N <10 ->
io:format("~p, ",[N] ),
for_loop(N+1);
for_loop(N+1);
for_loop(N) when N >=10->
if N=:=10 ->
if N=:=10 ->
io:format("~p\n",[N] )
end;
for_loop(N) ->
if N=:=5 ->
for_loop(N) ->
if N=:=5 ->
io:format("~p\n",[N] ),
for_loop(N+1)
end.

View file

@ -0,0 +1,3 @@
WRITE (6,1) (I,I = 1,10)
1 FORMAT (4(1X,I0,","),1X,I0)
END

View file

@ -0,0 +1,11 @@
function rng(n) {
return n ? rng(n - 1).concat(n) : [];
}
console.log(
rng(10).reduce(
function (a, x) {
return a + x.toString() + (x % 5 ? ', ' : '\n');
}, ''
)
);

View file

@ -0,0 +1,2 @@
1, 2, 3, 4, 5
6, 7, 8, 9, 10

View file

@ -0,0 +1,8 @@
for i in 1:10
print(i)
if i%5 == 0
println()
continue
end
print(", ")
end

View file

@ -1,12 +1,10 @@
use std::iter::range_inclusive;
fn main() {
for i in range_inclusive(1, 10) {
print!("{:d}", i);
if i % 5 == 0 {
print("\n");
continue;
for i in 1..10+1 {
print!("{}", i);
if i % 5 == 0 {
print!("\n");
continue;
}
print!(", ");
}
print(", ");
}
}

View file

@ -0,0 +1,8 @@
for i=1:10
printf("%2d ",i)
if modulo(i,5)~=0 then
printf(", ")
continue
end
printf("\n")
end