Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/SEDOLs/Smalltalk/sedols-1.st
Normal file
6
Task/SEDOLs/Smalltalk/sedols-1.st
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
String extend [
|
||||
includesAnyOf: aSet [
|
||||
aSet do: [ :e | (self includes: e) ifTrue: [ ^true ] ].
|
||||
^false
|
||||
]
|
||||
].
|
||||
43
Task/SEDOLs/Smalltalk/sedols-2.st
Normal file
43
Task/SEDOLs/Smalltalk/sedols-2.st
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
Object subclass: SEDOL [
|
||||
|weight charList|
|
||||
|
||||
initialize [
|
||||
weight := Array from: { 1. 3. 1. 7. 3. 9 }.
|
||||
charList :=
|
||||
('ABCDEFGHIJKLMNOPQRSTUVWXYZ' asOrderedCollection)
|
||||
collect: [ :c | ('AEIOU' includes: c) ifTrue: [ nil ] ifFalse: [ c ] ].
|
||||
]
|
||||
|
||||
SEDOL class >> new [
|
||||
^ (self basicNew) initialize
|
||||
]
|
||||
|
||||
"to be considered private"
|
||||
blindCheckDigit: aSEDOL [ |sum|
|
||||
sum := 0.
|
||||
aSEDOL keysAndValuesDo: [ :i :c |
|
||||
('0123456789' includes: c)
|
||||
ifTrue: [ sum := sum +
|
||||
((weight at: i) *
|
||||
(Number readFrom: (c asString readStream))).
|
||||
]
|
||||
ifFalse: [ sum := sum + (((charList indexOf: c) + 9) *
|
||||
(weight at: i))
|
||||
]
|
||||
].
|
||||
^ ((10 - (sum rem: 10)) rem: 10) displayString
|
||||
]
|
||||
|
||||
checked: aSEDOL [
|
||||
(aSEDOL size < 6) |
|
||||
(aSEDOL size > 7) |
|
||||
(aSEDOL asUppercase includesAnyOf: 'AEIOU' asSet )
|
||||
ifTrue: [ SystemExceptions.InvalidArgument
|
||||
signalOn: aSEDOL
|
||||
reason: 'Not a valid SEDOL'
|
||||
]
|
||||
ifFalse: [ |t| t := aSEDOL copyFrom: 1 to: 6.
|
||||
^ t , (self blindCheckDigit: t)
|
||||
]
|
||||
]
|
||||
].
|
||||
12
Task/SEDOLs/Smalltalk/sedols-3.st
Normal file
12
Task/SEDOLs/Smalltalk/sedols-3.st
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|sedol|
|
||||
sedol := SEDOL new.
|
||||
{ '710889'.
|
||||
'B0YBKJ'.
|
||||
'406566'.
|
||||
'B0YBLH'.
|
||||
'228276'.
|
||||
'B0YBKL'.
|
||||
'557910'.
|
||||
'B0YBKR'.
|
||||
'585284'.
|
||||
'B0YBKT' } do: [ :c | (sedol checked: c) displayNl ]
|
||||
22
Task/SEDOLs/Smalltalk/sedols-4.st
Normal file
22
Task/SEDOLs/Smalltalk/sedols-4.st
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#(
|
||||
'710889'
|
||||
'B0YBKJ'
|
||||
'406566'
|
||||
'B0YBLH'
|
||||
'228276'
|
||||
'B0YBKL'
|
||||
'557910'
|
||||
'B0YBKR'
|
||||
'585284'
|
||||
'B0YBKT'
|
||||
'B00030'
|
||||
) do:[:in |
|
||||
|um check|
|
||||
|
||||
sum := 0.
|
||||
(in to:6) with:#[1 3 1 7 3 9 ] do:[:ch :weight |
|
||||
sum := sum + (ch digitValue * weight).
|
||||
].
|
||||
check := (10 - (sum%10)) % 10.
|
||||
Transcript showCR: ( in,(Character digitValue:check))
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue