tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
12
Task/SEDOLs/Common-Lisp/sedols.lisp
Normal file
12
Task/SEDOLs/Common-Lisp/sedols.lisp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defun append-sedol-check-digit (sedol &key (start 0) (end (+ start 6)))
|
||||
(assert (<= 0 start end (length sedol)))
|
||||
(assert (= (- end start) 6))
|
||||
(loop
|
||||
:with checksum = 0
|
||||
:for weight :in '(1 3 1 7 3 9)
|
||||
:for index :upfrom start
|
||||
:do (incf checksum (* weight (digit-char-p (char sedol index) 36)))
|
||||
:finally (let* ((posn (- 10 (mod checksum 10)))
|
||||
(head (subseq sedol start end))
|
||||
(tail (digit-char posn)))
|
||||
(return (concatenate 'string head (list tail))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue