2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,5 +1,8 @@
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
;Task:
Create a program that, when run, would display all integers from &nbsp; '''1''' &nbsp; to &nbsp; <big><big> ''' <b> &infin; </b> ''' </big></big> &nbsp; (or any relevant implementation limit), &nbsp; in sequence &nbsp; (i.e. &nbsp; 1, 2, 3, 4, etc) &nbsp; if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integers are represented as a 32-bit unsigned value with 0 as the smallest representable value, the largest representable value would be 4,294,967,295. Some languages support arbitrarily-large numbers as a built-in feature, while others make use of a module or library.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. &nbsp; For example, if integers are represented as a 32-bit unsigned value with 0 as the smallest representable value, the largest representable value would be 4,294,967,295. &nbsp; Some languages support arbitrarily-large numbers as a built-in feature, while others make use of a module or library.
If appropriate, provide an example which reflect the language implementation's common built-in limits as well as an example which supports arbitrarily large numbers, and describe the nature of such limitations—or lack thereof.
<br><br>

View file

@ -0,0 +1,15 @@
* Integer sequence 06/05/2016
INTSEQED CSECT
USING INTSEQED,12
LR 12,15
LA 6,1 i=1
LOOP CVD 6,DW binary to pack decimal
MVC WTOMSG+4(12),EM12 load mask
ED WTOMSG+4(12),DW+2 packed dec to char
WTO MF=(E,WTOMSG) write to console
LA 6,1(6) i=i+1
B LOOP goto loop
WTOMSG DC 0F,H'80',H'0',CL80' '
DW DS 0D,PL8 pack dec 15num
EM12 DC X'402020202020202020202120' mask CL12 11num
END INTSEQED

View file

@ -0,0 +1,7 @@
ORG 0100H
MVI A, 0 ; move immediate
LOOP: INR A ; increment
; call 'PRINT' subroutine, if required
JMP LOOP ; jump unconditionally
END

View file

@ -0,0 +1,12 @@
begin
% print the integers from 1 onwards %
% Algol W only has 32-bit integers. When i reaches 2^32, %
% an integer overflow event would be raised which by default, %
% should terminate the program %
integer i;
i := 1;
while true do begin
write( i );
i := i + 1
end loop_forever ;
end.

View file

@ -0,0 +1,15 @@
.text
.global main
@ An ARM program that keeps incrementing R0 forever
@
@ If desired, a call to some 'PRINT' routine --
@ which would depend on the OS -- could be included
main:
mov r0, #0 @ start with R0 = 0
repeat:
@ call to 'PRINT' routine
add r0, r0, #1 @ increment R0
b repeat @ unconditional branch

View file

@ -4,6 +4,6 @@ procedure Integers is
begin
loop
Ada.Text_IO.Put_Line (Integer'Image (Value));
Value := Value + 1;
Value := Value + 1; -- raises exception Constraint_Error on overflow
end loop;
end Integers;

View file

@ -0,0 +1 @@
+[<<+>>[[<<"-----------"["+++++++++++"<]>]>[<<<<+>>+>>[>>]<]<]>>[>>]<<]

View file

@ -0,0 +1,9 @@
let
fun printInts(n) =
(
print(Int.toString(n) ^ "\n");
printInts(n+1)
)
in
printInts(1)
end;

View file

@ -0,0 +1,3 @@
i = Routine { inf.do { |i| i.yield } }; // return all integers, represented by a 64 bit signed float.
j = { inf.do { i.next.postln; 0.01.wait } }; // this prints them incrementally
j.play;