RosettaCodeData/Task/SEDOLs/Oforth/sedols.fth
2023-07-01 13:44:08 -04:00

5 lines
184 B
Forth

func: sedol(s)
[ 1, 3, 1, 7, 3, 9 ] s
zipWith(#[ dup isDigit ifTrue: [ '0' - ] else: [ 'A' - 10 + ] * ]) sum
10 mod 10 swap - 10 mod
StringBuffer new s << swap '0' + <<c ;