Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,22 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Order is
type IntArray is array (Positive range <>) of Integer;
List1 : IntArray := (1, 2, 3, 4, 5);
List2 : IntArray := (1, 2, 1, 5, 2, 2);
List3 : IntArray := (1, 2, 1, 5, 2);
List4 : IntArray := (1, 2, 1, 5, 2);
type Animal is (Rat, Cat, Elephant);
type AnimalArray is array (Positive range <>) of Animal;
List5 : AnimalArray := (Cat, Elephant, Rat, Cat);
List6 : AnimalArray := (Cat, Elephant, Rat);
List7 : AnimalArray := (Cat, Cat, Elephant);
begin
Put_Line (Boolean'Image (List1 > List2)); -- True
Put_Line (Boolean'Image (List2 > List3)); -- True
Put_Line (Boolean'Image (List3 > List4)); -- False, equal
Put_Line (Boolean'Image (List5 > List6)); -- True
Put_Line (Boolean'Image (List6 > List7)); -- True
end Order;

View file

@ -0,0 +1,4 @@
lex[a,b] := lexicalCompare[a, b] < 0 ? true : false
println[lex[ [1,2], [1,2,3] ]]
println[lex[ [1,2,4,3], [1,2,3] ]]

View file

@ -0,0 +1,9 @@
function order($as,$bs) {
if($as -and $bs) {
$a, $as = $as
$b, $bs = $bs
if($a -eq $b) {order $as $bs}
else{$a -lt $b}
} elseif ($bs) {$true} else {$false}
}
"$(order @(1,2,1,3,2) @(1,2,0,4,4,0,0,0))"

View file

@ -0,0 +1,16 @@
function Test-Order ([int[]]$ReferenceArray, [int[]]$DifferenceArray)
{
for ($i = 0; $i -lt $ReferenceArray.Count; $i++)
{
if ($ReferenceArray[$i] -lt $DifferenceArray[$i])
{
return $true
}
elseif ($ReferenceArray[$i] -gt $DifferenceArray[$i])
{
return $false
}
}
return ($ReferenceArray.Count -lt $DifferenceArray.Count) -or (Compare-Object $ReferenceArray $DifferenceArray) -eq $null
}

View file

@ -0,0 +1,5 @@
Test-Order -ReferenceArray 1, 2, 1, 3, 2 -DifferenceArray 1, 2, 0, 4, 4, 0, 0, 0
Test-Order -ReferenceArray 1, 2, 1, 3, 2 -DifferenceArray 1, 2, 2, 4, 4, 0, 0, 0
Test-Order -ReferenceArray 1, 2, 3 -DifferenceArray 1, 2
Test-Order -ReferenceArray 1, 2 -DifferenceArray 1, 2, 3
Test-Order -ReferenceArray 1, 2 -DifferenceArray 1, 2

View file

@ -0,0 +1,14 @@
lex_compare <- function(v1, v2){
ldiff <- length(v1)-length(v2)
endstate <- ldiff<0
iters <- ifelse(endstate, length(v1), length(v2))
for(i in seq_len(iters)){
if(v1[i]==v2[i]) next
else return(v1[i]<v2[i])
}
return(endstate)
}
lex_compare(c(1,2,1,3,2), c(1,2,0,4,4,0,0,0))
lex_compare(1, numeric(0))
lex_compare(numeric(0), 1)

View file

@ -0,0 +1,33 @@
Function order_list(arr1,arr2)
order_list = "FAIL"
n1 = UBound(arr1): n2 = UBound(arr2)
n = 0 : p = 0
If n1 > n2 Then
max = n2
Else
max = n1
End If
For i = 0 To max
If arr1(i) > arr2(i) Then
n = n + 1
ElseIf arr1(i) = arr2(i) Then
p = p + 1
End If
Next
If (n1 < n2 And n = 0) Or _
(n1 = n2 And n = 0 And p - 1 <> n1) Or _
(n1 > n2 And n = 0 And p = n2) Then
order_list = "PASS"
End If
End Function
WScript.StdOut.WriteLine order_list(Array(-1),Array(0))
WScript.StdOut.WriteLine order_list(Array(0),Array(0))
WScript.StdOut.WriteLine order_list(Array(0),Array(-1))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,-1))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,0))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,1))
WScript.StdOut.WriteLine order_list(Array(0,-1),Array(0))
WScript.StdOut.WriteLine order_list(Array(0,0),Array(0))
WScript.StdOut.WriteLine order_list(Array(0,0),Array(1))
WScript.StdOut.WriteLine order_list(Array(1,2,1,3,2),Array(1,2,0,4,4,0,0,0))