<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
(define title "SEDOL Validator")

(define (just-digits list1)
  (cond ((null? list1) '())
	((char-numeric? (car list1))
	 (cons (car list1) (just-digits (cdr list1))))
	(else (just-digits (cdr list1)))))

(define (string->digits str)
  (if (string? str)
      (list->string (just-digits (string->list str)))

(define-input (string->digits sedol))

(define (sedol-addend ch weight)
  (* (string->number (string ch)) weight))
(define (sedol-valid? str)
  (and (= 7 (string-length str))
       (zero? (remainder (apply + (map sedol-addend
				       (string->list str)
				       '(1 3 1 7 3 9 1)))

(define (sedol-digit7 str6)
  (modulo (- (apply + (map sedol-addend
			   (string->list str6)
			   '(1 3 1 7 3 9))))
<link rel=stylesheet type="text/css" href="[brlcab-top]brl.css">




[(brl-when (brl-nonblank? sedol)]
<strong>[sedol] is[(brl-unless (sedol-valid? sedol)] not[)] a valid SEDOL.</strong>

[(brl-when (= 6 (string-length sedol))]
<strong>However, [sedol (sedol-digit7 sedol)] is.</strong>

<p>SEDOL numbers are
<a href="http://www.prices.londonstockexchange.com/glossary.asp">defined</a>
by the London Stock Exchange as seven-digit numbers, the last of which
is a check digit.</p>

<form method="POST">
Enter a number:
<input type=text name=sedol>
<input type=submit value="Validate">

   <a href="[(brl-source-link brl-context)]">View Source</a></p>