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,40 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_SEDOL is
subtype SEDOL_String is String (1..6);
type SEDOL_Sum is range 0..9;
function Check (SEDOL : SEDOL_String) return SEDOL_Sum is
Weight : constant array (SEDOL_String'Range) of Integer := (1,3,1,7,3,9);
Sum : Integer := 0;
Item : Integer;
begin
for Index in SEDOL'Range loop
Item := Character'Pos (SEDOL (Index));
case Item is
when Character'Pos ('0')..Character'Pos ('9') =>
Item := Item - Character'Pos ('0');
when Character'Pos ('B')..Character'Pos ('D') |
Character'Pos ('F')..Character'Pos ('H') |
Character'Pos ('J')..Character'Pos ('N') |
Character'Pos ('P')..Character'Pos ('T') |
Character'Pos ('V')..Character'Pos ('Z') =>
Item := Item - Character'Pos ('A') + 10;
when others =>
raise Constraint_Error;
end case;
Sum := Sum + Item * Weight (Index);
end loop;
return SEDOL_Sum ((-Sum) mod 10);
end Check;
Test : constant array (1..10) of SEDOL_String :=
( "710889", "B0YBKJ", "406566", "B0YBLH", "228276",
"B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT"
);
begin
for Index in Test'Range loop
Put_Line (Test (Index) & Character'Val (Character'Pos ('0') + Check (Test (Index))));
end loop;
end Test_SEDOL;

View file

@ -1,15 +1,15 @@
ord0: to :integer `0`
ord7: to :integer `7`
ord0: to :integer '0'
ord7: to :integer '7'
c2v: function [c][
ordC: to :integer c
if? c < `A` -> return ordC - ord0
else -> return ordC - ord7
switch c < 'A' -> return ordC - ord0
-> return ordC - ord7
]
weight: [1 3 1 7 3 9]
checksum: function [sedol][
val: new 0
val: 0
loop .with:'i sedol 'ch ->
'val + weight\[i] * c2v ch
return to :char ord0 + (10 - val % 10) % 10

View file

@ -1,79 +0,0 @@
>>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. sedol.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT sedol-file ASSIGN "sedol.txt"
ORGANIZATION LINE SEQUENTIAL
FILE STATUS sedol-file-status.
DATA DIVISION.
FILE SECTION.
FD sedol-file.
01 sedol PIC X(6).
WORKING-STORAGE SECTION.
01 sedol-file-status PIC XX.
88 sedol-file-ok VALUE "00".
01 digit-num PIC 9 COMP.
01 digit-weights-area VALUE "1317391".
03 digit-weights PIC 9 OCCURS 7 TIMES.
01 weighted-sum-parts-area.
03 weighted-sum-parts PIC 9(3) COMP OCCURS 6 TIMES.
01 weighted-sum PIC 9(3) COMP.
01 check-digit PIC 9.
PROCEDURE DIVISION.
OPEN INPUT sedol-file
PERFORM UNTIL NOT sedol-file-ok
READ sedol-file
AT END
EXIT PERFORM
END-READ
MOVE FUNCTION UPPER-CASE(sedol) TO sedol
PERFORM VARYING digit-num FROM 1 BY 1 UNTIL digit-num > 6
EVALUATE TRUE
WHEN sedol (digit-num:1) IS ALPHABETIC-UPPER
IF sedol (digit-num:1) = "A" OR "E" OR "I" OR "O" OR "U"
DISPLAY "Invalid SEDOL: " sedol
EXIT PERFORM CYCLE
END-IF
COMPUTE weighted-sum-parts (digit-num) =
(FUNCTION ORD(sedol (digit-num:1)) - FUNCTION ORD("A")
+ 10) * digit-weights (digit-num)
WHEN sedol (digit-num:1) IS NUMERIC
MULTIPLY FUNCTION NUMVAL(sedol (digit-num:1))
BY digit-weights (digit-num)
GIVING weighted-sum-parts (digit-num)
WHEN OTHER
DISPLAY "Invalid SEDOL: " sedol
EXIT PERFORM CYCLE
END-EVALUATE
END-PERFORM
INITIALIZE weighted-sum
PERFORM VARYING digit-num FROM 1 BY 1 UNTIL digit-num > 6
ADD weighted-sum-parts (digit-num) TO weighted-sum
END-PERFORM
COMPUTE check-digit =
FUNCTION MOD(10 - FUNCTION MOD(weighted-sum, 10), 10)
DISPLAY sedol check-digit
END-PERFORM
CLOSE sedol-file
.
END PROGRAM sedol.

View file

@ -1,48 +0,0 @@
function Add-SEDOLCheckDigit
{
Param ( # Validate input as six-digit SEDOL number
[ValidatePattern( "^[0123456789bcdfghjklmnpqrstvwxyz]{6}$" )]
[parameter ( Mandatory = $True ) ]
[string]
$SixDigitSEDOL )
# Convert to array of single character strings, using type char as an intermediary
$SEDOL = [string[]][char[]]$SixDigitSEDOL
# Define place weights
$Weight = @( 1, 3, 1, 7, 3, 9 )
# Define character values (implicit in 0-based location within string)
$Characters = "0123456789abcdefghijklmnopqrstuvwxyz"
$CheckSum = 0
# For each digit, multiply the character value by the weight and add to check sum
0..5 | ForEach { $CheckSum += $Characters.IndexOf( $SEDOL[$_].ToLower() ) * $Weight[$_] }
# Derive the check digit from the partial check sum
$CheckDigit = ( 10 - $CheckSum % 10 ) % 10
# Return concatenated result
return ( $SixDigitSEDOL + $CheckDigit )
}
# Test
$List = @(
"710889"
"B0YBKJ"
"406566"
"B0YBLH"
"228276"
"B0YBKL"
"557910"
"B0YBKR"
"585284"
"B0YBKT"
"B00030"
)
ForEach ( $PartialSEDOL in $List )
{
Add-SEDOLCheckDigit -SixDigitSEDOL $PartialSEDOL
}

View file

@ -1,44 +0,0 @@
arr = Array("710889",_
"B0YBKJ",_
"406566",_
"B0YBLH",_
"228276",_
"B0YBKL",_
"557910",_
"B0YBKR",_
"585284",_
"B0YBKT",_
"12345",_
"A12345",_
"B00030")
For j = 0 To UBound(arr)
WScript.StdOut.Write arr(j) & getSEDOLCheckDigit(arr(j))
WScript.StdOut.WriteLine
Next
Function getSEDOLCheckDigit(str)
If Len(str) <> 6 Then
getSEDOLCheckDigit = " is invalid. Only 6 character strings are allowed."
Exit Function
End If
Set mult = CreateObject("Scripting.Dictionary")
With mult
.Add "1","1" : .Add "2", "3" : .Add "3", "1"
.Add "4","7" : .Add "5", "3" : .Add "6", "9"
End With
total = 0
For i = 1 To 6
s = Mid(str,i,1)
If s = "A" Or s = "E" Or s = "I" Or s = "O" Or s = "U" Then
getSEDOLCheckDigit = " is invalid. Vowels are not allowed."
Exit Function
End If
If Asc(s) >= 48 And Asc(s) <=57 Then
total = total + CInt(s) * CInt(mult.Item(CStr(i)))
Else
total = total + (Asc(s) - 55) * CInt(mult.Item(CStr(i)))
End If
Next
getSEDOLCheckDigit = (10 - total Mod 10) Mod 10
End Function