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,6 +0,0 @@
generic
type Element_Type is private;
type Index is (<>);
type Collection is array(Index) of Element_Type;
with function "<=" (Left, Right : Element_Type) return Boolean is <>;
procedure Gnome_Sort(Item : in out Collection);

View file

@ -1,25 +0,0 @@
procedure Gnome_Sort(Item : in out Collection) is
procedure Swap(Left, Right : in out Element_Type) is
Temp : Element_Type := Left;
begin
Left := Right;
Right := Temp;
end Swap;
I : Integer := Index'Pos(Index'Succ(Index'First));
J : Integer := I + 1;
begin
while I <= Index'Pos(Index'Last) loop
if Item(Index'Val(I - 1)) <= Item(Index'Val(I)) then
I := J;
J := J + 1;
else
Swap(Item(Index'Val(I - 1)), Item(Index'Val(I)));
I := I - 1;
if I = Index'Pos(Index'First) then
I := J;
J := J + 1;
end if;
end if;
end loop;
end Gnome_Sort;

View file

@ -1,19 +0,0 @@
with Gnome_Sort;
with Ada.Text_Io; use Ada.Text_Io;
procedure Gnome_Sort_Test is
type Index is range 0..9;
type Buf is array(Index) of Integer;
procedure Sort is new Gnome_Sort(Integer, Index, Buf);
A : Buf := (900, 700, 800, 600, 400, 500, 200, 100, 300, 0);
begin
for I in A'range loop
Put(Integer'Image(A(I)));
end loop;
New_Line;
Sort(A);
for I in A'range loop
Put(Integer'Image(A(I)));
end loop;
New_Line;
end Gnome_Sort_Test;

View file

@ -3,11 +3,10 @@ gnomeSort: function [items][
j: 2
arr: new items
while [i < size arr][
if? arr\[i-1] =< arr\[i] [
switch arr\[i-1] =< arr\[i] [
i: j
j: j + 1
]
else [
][
tmp: arr\[i]
arr\[i]: arr\[i-1]
arr\[i-1]: tmp

View file

@ -1,30 +0,0 @@
C-SORT SECTION.
C-000.
DISPLAY "SORT STARTING".
SET WB-IX-1 TO 2.
MOVE 1 TO WC-NEXT-POSN.
PERFORM E-GNOME UNTIL WC-NEXT-POSN > WC-SIZE.
DISPLAY "SORT FINISHED".
C-999.
EXIT.
E-GNOME SECTION.
E-000.
IF WB-ENTRY(WB-IX-1 - 1) NOT > WB-ENTRY(WB-IX-1)
ADD 1 TO WC-NEXT-POSN
SET WB-IX-1 TO WC-NEXT-POSN
ELSE
MOVE WB-ENTRY(WB-IX-1 - 1) TO WC-TEMP
MOVE WB-ENTRY(WB-IX-1) TO WB-ENTRY(WB-IX-1 - 1)
MOVE WC-TEMP TO WB-ENTRY(WB-IX-1)
SET WB-IX-1 DOWN BY 1
IF WB-IX-1 = 1
ADD 1 TO WC-NEXT-POSN
SET WB-IX-1 TO WC-NEXT-POSN.
E-999.
EXIT.

View file

@ -32,10 +32,10 @@ extension op
}
}
public program()
public Program()
{
var list := new int[]{3, 9, 4, 6, 8, 1, 7, 2, 5};
console.printLine("before:", list.asEnumerable());
console.printLine("after :", list.gnomeSort().asEnumerable())
Console.printLine("before:", list.asEnumerable());
Console.printLine("after :", list.gnomeSort().asEnumerable())
}

View file

@ -1,22 +0,0 @@
function gnomeSort(sequence s)
integer i,j
object temp
i = 1
j = 2
while i < length(s) do
if compare(s[i], s[i+1]) <= 0 then
i = j
j += 1
else
temp = s[i]
s[i] = s[i+1]
s[i+1] = temp
i -= 1
if i = 0 then
i = j
j += 1
end if
end if
end while
return s
end function

View file

@ -1,39 +0,0 @@
class GnomeSort {
@:generic
public static function sort<T>(arr:Array<T>) {
var i = 1;
var j = 2;
while (i < arr.length) {
if (Reflect.compare(arr[i - 1], arr[i]) <= 0) {
i = j++;
} else {
var temp = arr[i];
arr[i] = arr[i - 1];
arr[i - 1] = temp;
if (--i == 0) {
i = j++;
}
}
}
}
}
class Main {
static function main() {
var integerArray = [1, 10, 2, 5, -1, 5, -19, 4, 23, 0];
var floatArray = [1.0, -3.2, 5.2, 10.8, -5.7, 7.3,
3.5, 0.0, -4.1, -9.5];
var stringArray = ['We', 'hold', 'these', 'truths', 'to',
'be', 'self-evident', 'that', 'all',
'men', 'are', 'created', 'equal'];
Sys.println('Unsorted Integers: ' + integerArray);
GnomeSort.sort(integerArray);
Sys.println('Sorted Integers: ' + integerArray);
Sys.println('Unsorted Floats: ' + floatArray);
GnomeSort.sort(floatArray);
Sys.println('Sorted Floats: ' + floatArray);
Sys.println('Unsorted Strings: ' + stringArray);
GnomeSort.sort(stringArray);
Sys.println('Sorted Strings: ' + stringArray);
}
}

View file

@ -1,26 +1,24 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
with javascript_semantics
<span style="color: #008080;">function</span> <span style="color: #000000;">gnomeSort</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">j</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">2</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">i</span><span style="color: #0000FF;"><</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">object</span> <span style="color: #000000;">si</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">sn</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">si</span><span style="color: #0000FF;"><=</span><span style="color: #000000;">sn</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">j</span>
<span style="color: #000000;">j</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">sn</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">si</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">j</span>
<span style="color: #000000;">j</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">s</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
function gnomeSort(sequence s)
integer i = 1, j = 2
while i<length(s) do
object si = s[i],
sn = s[i+1]
if si<=sn then
i = j
j += 1
else
s[i] = sn
s[i+1] = si
i -= 1
if i=0 then
i = j
j += 1
end if
end if
end while
return s
end function
<span style="color: #0000FF;">?</span><span style="color: #000000;">gnomeSort</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shuffle</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)))</span>
<!--
?gnomeSort(shuffle(tagset(10)))

View file

@ -1,20 +0,0 @@
function gnomesort($a) {
$size, $i, $j = $a.Count, 1, 2
while($i -lt $size) {
if ($a[$i-1] -le $a[$i]) {
$i = $j
$j++
}
else {
$a[$i-1], $a[$i] = $a[$i], $a[$i-1]
$i--
if($i -eq 0) {
$i = $j
$j++
}
}
}
$a
}
$array = @(60, 21, 19, 36, 63, 8, 100, 80, 3, 87, 11)
"$(gnomesort $array)"

View file

@ -1,27 +0,0 @@
function gnomeSort( a )
dim i
dim j
i = 1
j = 2
do while i < ubound( a ) + 1
if a(i-1) <= a(i) then
i = j
j = j + 1
else
swap a(i-1), a(i)
i = i - 1
if i = 0 then
i = j
j = j + 1
end if
end if
loop
gnomeSort = a
end function
sub swap( byref x, byref y )
dim temp
temp = x
x = y
y = temp
end sub

View file

@ -1,22 +0,0 @@
dim a
dim b
a = array( "zanzibar", "aardvark","ampicillin","zulu","gogodala", "wolverhampton")
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( 234,567,345,568,2345,89,547,23,649,5769,456,456,567)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( true, false, true, true, false, false, true, false)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( 1,2,2,4,67789,-3,-45.99)
b = gnomeSort( a )
wscript.echo join(a, ", ")
a = array( now(), now()-1,now()+2)
b = gnomeSort( a )
wscript.echo join(a, ", ")

View file

@ -1,5 +0,0 @@
aardvark, ampicillin, gogodala, wolverhampton, zanzibar, zulu
23, 89, 234, 345, 456, 456, 547, 567, 567, 568, 649, 2345, 5769
True, True, True, True, False, False, False, False
-45.99, -3, 1, 2, 2, 4, 67789
2/02/2010 10:19:51 AM, 3/02/2010 10:19:51 AM, 5/02/2010 10:19:51 AM