Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Integer_sequence

View file

@ -0,0 +1,9 @@
;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. &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 @@
}:_:<:1:+%<:a:~$^:_:

View file

@ -0,0 +1,2 @@
L(i) 1..
print(i)

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,34 @@
ORG 0100H
BITS EQU 128 ; 128 bits of precision
BYTES EQU BITS / 8 ; Number of bytes we store those bits in
; Zero out the storage for our number
LXI H,BUFR ; HL points at BUFR. (HL is idiomatically used for pointers)
MVI C,BYTES ; C holds the number of bytes we'll use
XRA A ; XOR with A is a 1-byte instruction to set A to zero
INIT: MOV M,A ; Store 0 to address pointed to by HL
INX H ; Advance HL to the next byte
DCR C ; Count down
JNZ INIT ; Keep looping if we're not done
; The "very long integer" is zeroed, so start the loop
LOOP: CALL PRBUFR ; Output our number
LXI H,BUFR ; HL Points to BUFR
MVI C,BYTES ; Count down (assume fewer than 256 bytes in our integer)
NEXT: INR M ; Increment the byte pointed to by HL. Sets the zero flag
JNZ LOOP ; If the increment didn't overflow A, start the loop over
; This byte overflowed, so we need to advance to the next byte in our number
INX H ; We store our byes in order of increasing significance
DCR C ; Count down to make sure we don't overflow our buffer
JNZ NEXT ; jump to process the next, more significant byte
; If we get here, we have overflowed our integer!
HALT ; TODO: probably something other than "halt the CPU"
PRBUFR: ; TODO, a subroutine that shows all of the digits in BUFR on the console
; Assume that this code trashes all our registers...
RET
BUFR: ; This space will hold our number
; We zero this memory before the loop
END

View file

@ -0,0 +1,6 @@
main:
(
FOR i DO
printf(($g(0)","$,i))
OD
)

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

@ -0,0 +1,4 @@
BEGIN {
for( i=0; i != i + 1; i++ )
print( i )
}

View file

@ -0,0 +1,10 @@
PROC Main()
CARD i
i=0
DO
PrintF("%U ",i)
i==+1
UNTIL i=0
OD
RETURN

View file

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

View file

@ -0,0 +1,7 @@
with Ada.Text_IO;
procedure Positives is
begin
for Value in Positive'Range loop
Ada.Text_IO.Put_Line (Positive'Image (Value));
end loop;
end Positives;

View file

@ -0,0 +1,5 @@
10 I% = 1
20 PRINT I%;
30 I% = I% + 1
40 PRINT ", ";
50 GOTO 20

View file

@ -0,0 +1,24 @@
, 32646, 32647, 32648, 32649, 32650, 326
51, 32652, 32653, 32654, 32655, 32656, 3
2657, 32658, 32659, 32660, 32661, 32662,
32663, 32664, 32665, 32666, 32667, 3266
8, 32669, 32670, 32671, 32672, 32673, 32
674, 32675, 32676, 32677, 32678, 32679,
32680, 32681, 32682, 32683, 32684, 32685
, 32686, 32687, 32688, 32689, 32690, 326
91, 32692, 32693, 32694, 32695, 32696, 3
2697, 32698, 32699, 32700, 32701, 32702,
32703, 32704, 32705, 32706, 32707, 3270
8, 32709, 32710, 32711, 32712, 32713, 32
714, 32715, 32716, 32717, 32718, 32719,
32720, 32721, 32722, 32723, 32724, 32725
, 32726, 32727, 32728, 32729, 32730, 327
31, 32732, 32733, 32734, 32735, 32736, 3
2737, 32738, 32739, 32740, 32741, 32742,
32743, 32744, 32745, 32746, 32747, 3274
8, 32749, 32750, 32751, 32752, 32753, 32
754, 32755, 32756, 32757, 32758, 32759,
32760, 32761, 32762, 32763, 32764, 32765
, 32766, 32767
?ILLEGAL QUANTITY ERROR IN 30
]

View file

@ -0,0 +1,11 @@
IT'S SHOWTIME
HEY CHRISTMAS TREE n
YOU SET US UP @NO PROBLEMO
STICK AROUND @NO PROBLEMO
TALK TO THE HAND n
GET TO THE CHOPPER n
HERE IS MY INVITATION n
GET UP @NO PROBLEMO
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

View file

@ -0,0 +1,5 @@
i:0
while ø [
print i
inc 'i
]

View file

@ -0,0 +1,3 @@
x=0
Loop
TrayTip, Count, % ++x

View file

@ -0,0 +1,7 @@
While getKey(0)
End
0→I
Repeat getKey(0)
Disp I▶Dec,i
I++
EndIf I=0

View file

@ -0,0 +1,4 @@
10 LET A = 0
20 LET A = A + 1
30 PRINT A
40 GO TO 20

View file

@ -0,0 +1,2 @@
A = 0
DO: A = A + 1: PRINT A: LOOP 1

View file

@ -0,0 +1,6 @@
i = 1
do
print i
i += 1
until i = 0

View file

@ -0,0 +1,5 @@
*FLOAT 64
REPEAT
i += 1
PRINT TAB(0,0) i;
UNTIL FALSE

View file

@ -0,0 +1,9 @@
INSTALL @lib$+"HIMELIB"
PROC_himeinit("")
reg% = 1
PROC_hiputdec(reg%, "0")
REPEAT
SYS `hi_Incr`, ^reg%, ^reg%
PRINT TAB(0,0) FN_higetdec(reg%);
UNTIL FALSE

View file

@ -0,0 +1,2 @@
_while_ {𝔽𝔾𝔽_𝕣_𝔾𝔽𝔾𝕩}
(1+•Show) _while_ () 1

View file

@ -0,0 +1,6 @@
@echo off
set number=0
:loop
set /a number+=1
echo %number%
goto loop

View file

@ -0,0 +1 @@
while (++i) i

View file

@ -0,0 +1,2 @@
qNP<
_1>{d

View file

@ -0,0 +1 @@
_1F6~@{PN@J

View file

@ -0,0 +1 @@
1+:0`!#@_:.55+,

View file

@ -0,0 +1 @@
0:?n&whl'out$(1+!n:?n)

View file

@ -0,0 +1,4 @@
++++++++++>>>+[[->>+<[+>->+<<---------------------------------------
-------------------[>>-<++++++++++<[+>-<]]>[-<+>]<++++++++++++++++++
++++++++++++++++++++++++++++++>]<[<]>>[-<+++++++++++++++++++++++++++
++++++++++++++++++++++>]>]>[>>>]<<<[.<<<]<.>>>+]

View file

@ -0,0 +1,4 @@
++++++++++>>-[>+[->>+<[+>->+<<--------------------------------------
--------------------[>>-<++++++++++<[+>-<]]>[-<+>]<+++++++++++++++++
+++++++++++++++++++++++++++++++>]<[<]>>[-<++++++++++++++++++++++++++
+++++++++++++++++++++++>]>]>[>>>]<<<[.<<<]<.>>-]

View file

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

View file

@ -0,0 +1,6 @@
i = 1
loop {
p i
i = i + 1
}

View file

@ -0,0 +1 @@
1R@

View file

@ -0,0 +1,11 @@
#include <cstdint>
#include <iostream>
#include <limits>
int main()
{
auto i = std::uintmax_t{};
while (i < std::numeric_limits<decltype(i)>::max())
std::cout << ++i << '\n';
}

View file

@ -0,0 +1,19 @@
// Using the proposed unbounded integer library
#include <iostream>
#include <seminumeric>
int main()
{
try
{
auto i = std::experimental::seminumeric::integer{};
while (true)
std::cout << ++i << '\n';
}
catch (...)
{
// Do nothing
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Numerics;
class Program
{
static void Main()
{
BigInteger i = 1;
while (true)
{
Console.WriteLine(i++);
}
}
}

View file

@ -0,0 +1,9 @@
#include <stdio.h>
int main()
{
unsigned int i = 0;
while (++i) printf("%u\n", i);
return 0;
}

View file

@ -0,0 +1,14 @@
#include <gmp.h>
int main()
{
mpz_t i;
mpz_init(i); /* zero now */
while (1) {
mpz_add_ui(i, i, 1); /* i = i + 1 */
gmp_printf("%Zd\n", i);
}
return 0;
}

View file

@ -0,0 +1,29 @@
#include <openssl/bn.h> /* BN_*() */
#include <openssl/err.h> /* ERR_*() */
#include <stdio.h> /* fprintf(), puts() */
void
fail(const char *message)
{
fprintf(stderr, "%s: error 0x%08lx\n", ERR_get_error());
exit(1);
}
int
main()
{
BIGNUM i;
char *s;
BN_init(&i);
for (;;) {
if (BN_add_word(&i, 1) == 0)
fail("BN_add_word");
s = BN_bn2dec(&i);
if (s == NULL)
fail("BN_bn2dec");
puts(s);
OPENSSL_free(s);
}
/* NOTREACHED */
}

View file

@ -0,0 +1,18 @@
% This iterator will generate all integers until the built-in type
% overflows. It is a signed machine-sized integer; so 64 bits on
% a modern machine. After that it will raise an exception.
to_infinity_and_beyond = iter () yields (int)
i: int := 0
while true do
i := i + 1
yield(i)
end
end to_infinity_and_beyond
start_up = proc ()
po: stream := stream$primary_output()
for i: int in to_infinity_and_beyond() do
stream$putl(po, int$unparse(i))
end
end start_up

View file

@ -0,0 +1,16 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Int-Sequence.
DATA DIVISION.
WORKING-STORAGE SECTION.
* *> 36 digits is the largest size a numeric field can have.
01 I PIC 9(36).
PROCEDURE DIVISION.
* *> Display numbers until I overflows.
PERFORM VARYING I FROM 1 BY 1 UNTIL I = 0
DISPLAY I
END-PERFORM
GOBACK
.

View file

@ -0,0 +1,4 @@
for(1 => int i; i < Math.INT_MAX; i ++)
{
<<< i >>>;
}

View file

@ -0,0 +1,5 @@
module IntegerSequence
import StdEnv
Start = [x \\ x <- [1..]]

View file

@ -0,0 +1 @@
(map println (next (range)))

View file

@ -0,0 +1,35 @@
# This very limited BCD-based collection of functions
# makes it easy to count very large numbers. All arrays
# start off with the ones columns in position zero.
# Using arrays of decimal-based digits to model integers
# doesn't make much sense for most tasks, but if you
# want to keep counting forever, this does the trick.
BcdInteger =
from_string: (s) ->
arr = []
for c in s
arr.unshift parseInt(c)
arr
render: (arr) ->
s = ''
for elem in arr
s = elem.toString() + s
s
succ: (arr) ->
arr = (elem for elem in arr)
i = 0
while arr[i] == 9
arr[i] = 0
i += 1
arr[i] ||= 0
arr[i] += 1
arr
# To start counting from 1, change the next line!
big_int = BcdInteger.from_string "199999999999999999999999999999999999999999999999999999"
while true
console.log BcdInteger.render big_int
big_int = BcdInteger.succ big_int

View file

@ -0,0 +1,6 @@
> coffee foo.coffee | head -5
199999999999999999999999999999999999999999999999999999
200000000000000000000000000000000000000000000000000000
200000000000000000000000000000000000000000000000000001
200000000000000000000000000000000000000000000000000002
200000000000000000000000000000000000000000000000000003

View file

@ -0,0 +1 @@
(loop for i from 1 do (print i))

View file

@ -0,0 +1,2 @@
(defun pp (x) (pp (1+ (print x))))
(funcall (compile 'pp) 1) ; it's less likely interpreted mode will eliminate tails

View file

@ -0,0 +1,14 @@
MODULE IntegerSequence;
IMPORT StdLog;
PROCEDURE Do*;
VAR
i: INTEGER;
BEGIN
FOR i := 0 TO MAX(INTEGER) DO;
StdLog.Int(i)
END;
StdLog.Ln
END Do;
END IntegerSequence.

View file

@ -0,0 +1,3 @@
start: ADD one
JMP start
one: 1

View file

@ -0,0 +1,8 @@
include "cowgol.coh";
var n: uint32 := 1;
while n != 0 loop;
print_i32(n);
print_nl();
n := n + 1;
end loop;

View file

@ -0,0 +1,45 @@
include "cowgol.coh";
sub print_back(s: [uint8]) is
while [s] != 0 loop;
print_char([s]);
s := @prev s;
end loop;
print_nl();
end sub;
sub incr(n: [uint8]): (r: [uint8]) is
r := n;
while [n] != 0 loop;
n := @prev n;
end loop;
n := @next n;
loop
if [n] == 0 then
[n] := '1';
[@next n] := 0;
r := n;
break;
elseif [n] == '9' then
[n] := '0';
n := @next n;
continue;
else
[n] := [n] + 1;
break;
end if;
end loop;
end sub;
sub init(n: [uint8]): (r: [uint8]) is
[n] := 0;
[n+1] := '0';
[n+2] := 0;
r := n+1;
end sub;
var infnum := init(LOMEM);
loop
infnum := incr(infnum);
print_back(infnum);
end loop;

View file

@ -0,0 +1,3 @@
require "big"
(1.to_big_i ..).each { |i| puts i }

View file

@ -0,0 +1,7 @@
import std.stdio, std.bigint;
void main() {
BigInt i;
while (true)
writeln(++i);
}

View file

@ -0,0 +1,36 @@
import std.stdio, std.traits, std.bigint, std.string;
void integerSequence(T)() if (isIntegral!T || is(T == BigInt)) {
T now = 1;
T max = 0;
static if (!is(T == BigInt))
max = T.max;
do
write(now, " ");
while (now++ != max);
writeln("\nDone!");
}
void main() {
writeln("How much time do you have?");
writeln(" 0. I'm in hurry.");
writeln(" 1. I've some time.");
writeln(" 2. I'm on vacation.");
writeln(" 3. I'm unemployed...");
writeln(" 4. I'm immortal!");
write("Enter 0-4 or nothing to quit: ");
string answer;
readf("%s\n", &answer);
switch (answer.toLower()) {
case "0": integerSequence!ubyte(); break;
case "1": integerSequence!short(); break;
case "2": integerSequence!uint(); break;
case "3": integerSequence!long(); break;
case "4": integerSequence!BigInt(); break;
default: writeln("\nBye bye!"); break;
}
}

View file

@ -0,0 +1,5 @@
$ i = 1
$ loop:
$ write sys$output i
$ i = i + 1
$ goto loop

View file

@ -0,0 +1,4 @@
var i: Integer;
for i:=1 to High(i) do
PrintLn(i);

View file

@ -0,0 +1 @@
1[p1+lpx]dspx

View file

@ -0,0 +1,10 @@
program IntegerSequence;
{$APPTYPE CONSOLE}
var
i: Integer;
begin
for i := 1 to High(i) do
WriteLn(i);
end.

View file

@ -0,0 +1,5 @@
var n = 0
while true {
n += 1
print(n)
}

View file

@ -0,0 +1 @@
for i in int > 0 { println(i) }

View file

@ -0,0 +1,22 @@
[ Integer sequence
================
A program for the EDSAC
Displays integers 1,2,3...
in binary form in the first
word of storage tank 2
until stopped
Works with Initial Orders 2 ]
T56K [ set load point ]
GK [ set base address ]
A3@ [ increment accumulator ]
U64F [ copy accumulator to 64 ]
E@ [ jump to base address ]
P0D [ constant: 1 ]
EZPF [ begin at load point ]

View file

@ -0,0 +1,7 @@
.............
A%=0
LOOP
A%=A%+1
PRINT(A%;)
END LOOP
.............

View file

@ -0,0 +1,10 @@
max = pow 2 53
repeat
print i
if i = 10
print ".\n."
i = max - 10
.
until i = max
i += 1
.

View file

@ -0,0 +1,2 @@
(lib 'bigint) ;; arbitrary length integers
(for ((n (in-naturals))) (writeln n))

View file

@ -0,0 +1,22 @@
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Run application.
do
from
number := 0
until
number = number.max_value
loop
print(number)
print(", ")
number := number + 1
end
end
number:INTEGER_64
end

View file

@ -0,0 +1,12 @@
import extensions;
public program()
{
var i := 0u;
while (true)
{
console.printLine(i);
i += 1u
}
}

View file

@ -0,0 +1 @@
Stream.iterate(1, &(&1+1)) |> Enum.each(&(IO.puts &1))

View file

@ -0,0 +1,2 @@
(dotimes (i most-positive-fixnum)
(message "%d" (1+ i)))

View file

@ -0,0 +1 @@
F = fun(FF, I) -> io:format("~p~n", [I]), FF(FF, I + 1) end, F(F,0).

View file

@ -0,0 +1,6 @@
integer i
i = 0
while 1 do
? i
i += 1
end while

View file

@ -0,0 +1,6 @@
// lazy sequence of integers starting with i
let rec integers i =
seq { yield i
yield! integers (i+1) }
Seq.iter (printfn "%d") (integers 1)

View file

@ -0,0 +1 @@
let integers = Seq.initInfinite id

View file

@ -0,0 +1 @@
let integers n = Seq.initInfinite ((+) n)

View file

@ -0,0 +1,2 @@
let inline numbers n =
Seq.unfold (fun n -> Some (n, n + LanguagePrimitives.GenericOne)) n

View file

@ -0,0 +1,2 @@
USE: lists.lazy
1 lfrom [ . ] leach

View file

@ -0,0 +1,12 @@
class Main
{
public static Void main()
{
i := 1
while (true)
{
echo (i)
i += 1
}
}
}

View file

@ -0,0 +1,2 @@
n:=0;
while 1 do !n;!' '; n:=n+1 od

View file

@ -0,0 +1,2 @@
0>:n1+v
^o" "<

View file

@ -0,0 +1,2 @@
: ints ( -- )
0 begin 1+ dup cr u. dup -1 = until drop ;

View file

@ -0,0 +1,13 @@
program Intseq
implicit none
integer, parameter :: i64 = selected_int_kind(18)
integer(i64) :: n = 1
! n is declared as a 64 bit signed integer so the program will display up to
! 9223372036854775807 before overflowing to -9223372036854775808
do
print*, n
n = n + 1
end do
end program

View file

@ -0,0 +1,14 @@
' FB 1.05.0 Win64
' FB does not natively support arbitrarily large integers though support can be added
' by using an external library such as GMP. For now we will just use an unsigned integer (32bit).
Print "Press Ctrl + C to stop the program at any time"
Dim i As UInteger = 1
Do
Print i
i += 1
Loop Until i = 0 ' will wrap back to 0 when it reaches 4,294,967,296
Sleep

View file

@ -0,0 +1,6 @@
i=0
while true
{
println[i]
i = i + 1
}

View file

@ -0,0 +1 @@
for i <- 1.. do println( i )

View file

@ -0,0 +1 @@
fun main(n: int): [n]int = iota n

View file

@ -0,0 +1,12 @@
include "NSLog.incl"
UInt64 i = 1
while ( i < ULLONG_MAX )
NSLog( @"%llu\n", i )
i++
wend
// NSLog( @"Maximum Unsigned long long: %llu", ULLONG_MAX )
HandleEvents

View file

@ -0,0 +1,11 @@
InfiniteLoop := function()
local n;
n := 1;
while true do
Display(n);
n := n + 1;
od;
end;
# Prepare some coffee
InfiniteLoop();

View file

@ -0,0 +1,6 @@
Start,Programs,Accessories,Calculator,
Button:[plus],Button:1,Button:[equals],Button:[plus],Button:1,Button:[equals],
Button:[plus],Button:1,Button:[equals],Button:[plus],Button:1,Button:[equals],
Button:[plus],Button:1,Button:[equals],Button:[plus],Button:1,Button:[equals],
Button:[plus],Button:1,Button:[equals],Button:[plus],Button:1,Button:[equals],
Button:[plus],Button:1,Button:[equals],Button:[plus],Button:1,Button:[equals]

View file

@ -0,0 +1,4 @@
10 A#=1
20 PRINT A#
30 A#=A#+1
40 GOTO 20

View file

@ -0,0 +1,9 @@
package main
import "fmt"
func main() {
for i := 1;; i++ {
fmt.Println(i)
}
}

View file

@ -0,0 +1,13 @@
package main
import (
"big"
"fmt"
)
func main() {
one := big.NewInt(1)
for i := big.NewInt(1);; i.Add(i, one) {
fmt.Println(i)
}
}

View file

@ -0,0 +1,8 @@
// 32-bit 2's-complement signed integer (int/Integer)
for (def i = 1; i > 0; i++) { println i }
// 64-bit 2's-complement signed integer (long/Long)
for (def i = 1L; i > 0; i+=1L) { println i }
// Arbitrarily-long binary signed integer (BigInteger)
for (def i = 1g; ; i+=1g) { println i }

View file

@ -0,0 +1 @@
mapM_ print [1..]

View file

@ -0,0 +1 @@
putStr $ unlines $ map show [1..]

View file

@ -0,0 +1,2 @@
U64 i = 0;
while (++i) Print("%d\n", i);

View file

@ -0,0 +1,3 @@
100 FOR I=1 TO INF
110 PRINT I;
120 NEXT

Some files were not shown because too many files have changed in this diff Show more