Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,2 +0,0 @@
S : String := "12345";
S := Ada.Strings.Fixed.Trim(Source => Integer'Image(Integer'Value(S) + 1), Side => Ada.Strings.Both);

View file

@ -1,3 +0,0 @@
Global $x = "12345"
$x += 1
MsgBox(0,"",$x)

View file

@ -1,14 +0,0 @@
PROGRAM-ID. increment-num-str.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 str PIC X(5) VALUE "12345".
01 num REDEFINES str PIC 9(5).
PROCEDURE DIVISION.
DISPLAY str
ADD 1 TO num
DISPLAY str
GOBACK
.

View file

@ -1,13 +0,0 @@
PROGRAM-ID. increment-num-str.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 num-str PIC 9(5) VALUE 12345.
PROCEDURE DIVISION.
DISPLAY num-str
ADD 1 TO num-str
DISPLAY num-str
GOBACK
.

View file

@ -1,6 +1,6 @@
import extensions;
public program()
public Program()
{
var s := "12345";
s := (s.toInt() + 1).toString();

View file

@ -1 +0,0 @@
(1+ (string-to-number "12345"))

View file

@ -1,12 +0,0 @@
include get.e
function val(sequence s)
sequence x
x = value(s)
return x[2]
end function
sequence s
s = "12345"
s = sprintf("%d",{val(s)+1})

View file

@ -13,32 +13,33 @@ program StrInc;
system.SysUtils;
{$ENDIF}
type
myString = AnsiString; // String[32];//
tMyNumString = Ansistring; //string[31];//
function IncLoop(ps: pChar;le,Base: NativeInt):NativeInt;inline;
//Add 1 and correct carry
//returns 0, if no overflow, else 1
var
dg: nativeInt;
dgt: nativeInt;
Begin
//convert base to the highest char in base 2 > '1' ;10 -> '9'
base += Ord('0')-1;
dec(le);//ps is 0-based
dg := ord(ps[le])+(-ord('0')+1);
result := 0;
result := 0;
repeat
IF dg < base then
dgt := ord(ps[le]);
IF dgt < base then
begin
ps[le] := chr(dg+ord('0'));
ps[le] := chr(dgt+1);
EXIT;
end;
ps[le] := '0';
dec(le);
dg := ord(ps[le])+(-ord('0')+1);
until (le<0);
result:= 1;
end;
procedure IncIntStr(base:NativeInt;var s:myString);
procedure IncIntStr(base:NativeInt;var s:tMyNumString);
var
le: NativeInt;
begin
@ -53,13 +54,32 @@ begin
end;
end;
procedure IncMyString(var NumString: tMyNumString);
var
i: integer;
f_code: word;
begin
// string to num
val(Numstring,i,f_code);
//num to string
if f_code= 0 then
str(i+1,NumString);
end;
procedure IncMyStringOrg(var NumString: tMyNumString);
var
i: integer;
begin
readStr(NumString, i);
writeStr(NumString, succ(i));
end;
const
ONE_BILLION = 1000*1000*1000;
strLen = 26;
MAX = 1 shl strLen -1;
var
s : myString;
s : tMyNumString;
i,base : nativeInt;
T0: TDateTime;
Begin
@ -76,22 +96,31 @@ Begin
For i := 1 to MAX do
IncIntStr(Base,s);
T0 := (time-T0)*86400;
if base = 10 then
writeln(' IncAnsiString '); ;
writeln(s:strLen,' base ',base:2,T0:8:3,' s');
end;
writeln;
writeln('One billion digits "9"');
setlength(s,ONE_BILLION+1);
s[1]:= '0';//don't measure setlength in IncIntStr
fillchar(s[2],length(s)-1,'9');
writeln('first 5 digits ',s[1],s[2],s[3],s[4],s[5]);
writeln(' val -> str ');
setlength(s,1);
s[1]:= '0';
T0 := time;
IncIntStr(10,s);
For i := 1 to MAX do
IncMyString(s);
T0 := (time-T0)*86400;
writeln(length(s):10,T0:8:3,' s');
writeln('first 5 digits ',s[1],s[2],s[3],s[4],s[5]);
writeln(s:strLen,' base ',10:2,T0:8:3,' s');
writeln(' readstr -> writestring ');
setlength(s,1);
s[1]:= '0';
T0 := time;
For i := 1 to MAX do
IncMyStringOrg(s);
T0 := (time-T0)*86400;
writeln(s:strLen,' base ',10:2,T0:8:3,' s');
s:='';
{$IFDEF WINDOWS}
{$IFDEF WINDOWS}
readln;
{$ENDIF}
end.

View file

@ -1,2 +0,0 @@
$s = "12345"
$t = [string] ([int] $s + 1)

View file

@ -1,21 +0,0 @@
REBOL [
Title: "Increment Numerical String"
URL: http://rosettacode.org/wiki/Increment_numerical_string
]
; Note the use of unusual characters in function name. Also note that
; because REBOL collects terms from right to left, I convert the
; string argument (s) to integer first, then add that result to one.
s++: func [s][to-string 1 + to-integer s]
; Examples. Because the 'print' word actually evaluates the block
; (it's effectively a 'reduce' that gets printed space separated),
; it's possible for me to assign the test string to 'x' and have it
; printed as a side effect. At the end, 'x' is available to submit to
; the 's++' function. I 'mold' the return value of s++ to make it
; obvious that it's still a string.
print [x: "-99" "plus one equals" mold s++ x]
print [x: "42" "plus one equals" mold s++ x]
print [x: "12345" "plus one equals" mold s++ x]