USING: combinators combinators.short-circuit formatting io kernel math math.parser regexp sequences unicode ; IN: rosetta-code.sedols ] [ 55 - ] if ; : sedol-checksum ( seq -- n ) [ sedol-value ] { } map-as weights [ * ] 2map sum ; : (sedol-check-digit) ( seq -- str ) sedol-checksum 10 mod 10 swap - 10 mod number>string ; PRIVATE> : sedol-check-digit ( seq -- str ) dup sedol-valid? [ (sedol-check-digit) ] [ sedol-error ] if ; : sedol-demo ( -- ) "SEDOL Check digit\n====== ===========" print input [ dup sedol-check-digit "%-6s %s\n" printf ] each ; MAIN: sedol-demo