Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1 +1,3 @@
Start an integer value at 1024. Loop while it is greater than 0. Print the value (with a newline) and divide it by two each time through the loop.
{{omit from|GUISS|No loops and we cannot read values}}
Start an integer value at 1024. Loop while it is greater than 0.
Print the value (with a newline) and divide it by two each time through the loop.

View file

@ -1,2 +1,5 @@
---
category:
- Conditional loops
- Simple
note: Iteration

View file

@ -0,0 +1,27 @@
WHILE CSECT , This program's control section
BAKR 14,0 Caller's registers to linkage stack
LR 12,15 load entry point address into Reg 12
LA 13,0 inidicate caller no savearea
USING WHILE,12 tell assembler we use Reg 12 as base
XR 3,3 Register 3 zero.
XR 4,4 clear even divident reg
LA 5,1024 load odd divident reg
LA 9,2 divisor in reg 9
LA 8,WTOLEN address of WTO area in Reg 8
MVC WTOTXT,=C'1024'
WTO TEXT=(8) write to operator initial value 1024
LOOP DS 0H
DR 4,9 divide r4/5 by r9
CLR 3,4 less than zero?
BL RETURN yes, return
CVD 5,PACKED convert result to (packed) decimal
OI PACKED+7,X'0F' prepare unpack
XC WTOTXT,WTOTXT clear wto text
UNPK WTOTXT,PACKED packed decimal to zoned (printable)
WTO TEXT=(8) and write-to-operator
B LOOP loop.
RETURN PR , return to caller.
WTOLEN DC H'4' fixed WTO length of four
WTOTXT DS CL4
PACKED DS CL8
END WHILE

View file

@ -0,0 +1,7 @@
INTEGER I;
I:=1024;
WHILE I>0 DO
BEGIN
OUTINT(I);
I:=I/2
END

View file

@ -0,0 +1 @@
1024:?n & whl'(!n:>0 & out$!n & div$(!n.2):?n)

View file

@ -0,0 +1,4 @@
(let ((i 1024))
(while (> i 0)
(message "%d" i)
(setq i (/ i 2))))

View file

@ -13,21 +13,5 @@ C Handle I.
C Jump back to before the IF block.
GOTO 10
ENDIF
C This is an alternative while loop with labels on both ends. This
C will use the condition as a break rather than create an entire
C IF block. Which you use is up to you, but be aware that you must
C use this one if you plan on allowing for breaks.
I = 1024
20 CONTINUE
C If condition is false, break.
IF (I .LE. 0) GOTO 30
C Handle I.
WRITE (*,*) I
I = I / 2
C Jump back to the "loop" beginning.
GOTO 20
30 CONTINUE
STOP
END

View file

@ -0,0 +1,12 @@
PROGRAM LOOPWHILE
INTEGER I
C FORTRAN 66 does not have IF block.
I = 1024
10 CONTINUE
IF (I .LE. 0) GOTO 20
WRITE (*,*) I
I = I / 2
GOTO 10
20 CONTINUE
STOP
END

View file

@ -0,0 +1,4 @@
(let (i 1024)
(while (> i 0)
(println i)
(setq i (/ i 2))))

View file

@ -0,0 +1,7 @@
main: func {
value := 1024
while (value > 0) {
value toString() println()
value /= 2
}
}

View file

@ -0,0 +1,5 @@
while(0) :- !.
while(X) :-
writeln(X),
X1 is X // 2,
while(X1).

View file

@ -0,0 +1 @@
?- while(1024).

View file

@ -1,2 +0,0 @@
while(0) :- !.
while(X) :- X>0,write(X), nl, X1 is X // 2, while(X1).

View file

@ -1,2 +1,2 @@
i = 1024
puts i or i /= 2 while i > 0
puts i = 1024
puts i /= 2 while i > 0

View file

@ -0,0 +1,7 @@
fn main() {
let mut n = 1024i;
while n > 0 {
println!("{}", n);
n /= 2;
}
}

View file

@ -0,0 +1,5 @@
1024→I
While I>0
Disp I
I/2→I
End

View file

@ -0,0 +1,5 @@
let i = 1024
while i > 0
echo i
let i = i / 2
endwhile