Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Conditional loops
|
||||
- Simple
|
||||
note: Iteration
|
||||
|
|
|
|||
27
Task/Loops-While/360-Assembly/loops-while.360
Normal file
27
Task/Loops-While/360-Assembly/loops-while.360
Normal 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
|
||||
7
Task/Loops-While/ALGOL-60/loops-while.alg
Normal file
7
Task/Loops-While/ALGOL-60/loops-while.alg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
INTEGER I;
|
||||
I:=1024;
|
||||
WHILE I>0 DO
|
||||
BEGIN
|
||||
OUTINT(I);
|
||||
I:=I/2
|
||||
END
|
||||
1
Task/Loops-While/Bracmat/loops-while.bracmat
Normal file
1
Task/Loops-While/Bracmat/loops-while.bracmat
Normal file
|
|
@ -0,0 +1 @@
|
|||
1024:?n & whl'(!n:>0 & out$!n & div$(!n.2):?n)
|
||||
4
Task/Loops-While/Emacs-Lisp/loops-while.l
Normal file
4
Task/Loops-While/Emacs-Lisp/loops-while.l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(let ((i 1024))
|
||||
(while (> i 0)
|
||||
(message "%d" i)
|
||||
(setq i (/ i 2))))
|
||||
|
|
@ -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
|
||||
|
|
|
|||
12
Task/Loops-While/Fortran/loops-while-3.f
Normal file
12
Task/Loops-While/Fortran/loops-while-3.f
Normal 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
|
||||
4
Task/Loops-While/NewLISP/loops-while.newlisp
Normal file
4
Task/Loops-While/NewLISP/loops-while.newlisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(let (i 1024)
|
||||
(while (> i 0)
|
||||
(println i)
|
||||
(setq i (/ i 2))))
|
||||
7
Task/Loops-While/OOC/loops-while.ooc
Normal file
7
Task/Loops-While/OOC/loops-while.ooc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
main: func {
|
||||
value := 1024
|
||||
while (value > 0) {
|
||||
value toString() println()
|
||||
value /= 2
|
||||
}
|
||||
}
|
||||
5
Task/Loops-While/Prolog/loops-while-1.pro
Normal file
5
Task/Loops-While/Prolog/loops-while-1.pro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
while(0) :- !.
|
||||
while(X) :-
|
||||
writeln(X),
|
||||
X1 is X // 2,
|
||||
while(X1).
|
||||
1
Task/Loops-While/Prolog/loops-while-2.pro
Normal file
1
Task/Loops-While/Prolog/loops-while-2.pro
Normal file
|
|
@ -0,0 +1 @@
|
|||
?- while(1024).
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
while(0) :- !.
|
||||
while(X) :- X>0,write(X), nl, X1 is X // 2, while(X1).
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
i = 1024
|
||||
puts i or i /= 2 while i > 0
|
||||
puts i = 1024
|
||||
puts i /= 2 while i > 0
|
||||
|
|
|
|||
7
Task/Loops-While/Rust/loops-while.rust
Normal file
7
Task/Loops-While/Rust/loops-while.rust
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
let mut n = 1024i;
|
||||
while n > 0 {
|
||||
println!("{}", n);
|
||||
n /= 2;
|
||||
}
|
||||
}
|
||||
5
Task/Loops-While/TI-83-BASIC/loops-while.ti-83
Normal file
5
Task/Loops-While/TI-83-BASIC/loops-while.ti-83
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
1024→I
|
||||
While I>0
|
||||
Disp I
|
||||
I/2→I
|
||||
End
|
||||
5
Task/Loops-While/Vim-Script/loops-while.vim
Normal file
5
Task/Loops-While/Vim-Script/loops-while.vim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let i = 1024
|
||||
while i > 0
|
||||
echo i
|
||||
let i = i / 2
|
||||
endwhile
|
||||
Loading…
Add table
Add a link
Reference in a new issue