Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[Fun] Sedol

 [1/2] from: hallvard:ystad:babelserver at: 16-Feb-2008 0:48


Hi list Who will find the shortest AND most readable (and most elegant?) rebol implementation of a sedol validation code? (cf. http://en.wikipedia.org/wiki/SEDOL - 17 lines of VBA). HY

 [2/2] from: andreas::bolka::gmx::net at: 19-Feb-2008 0:07


Saturday, February 16, 2008, 12:48:25 AM, Hallvard wrote:
> Who will find the shortest AND most readable (and most elegant?) > rebol= implementation of a sedol validation code? (cf. > http://en.wikipedia.org/wiki/SEDOL - 17 lines of VBA).
Not REBOL, but for comparison purposes: K3: sedol:{(10-(+/(1 3 1 7 3 9)*{:[57<x;x-55;x-48]}'_ic x)!10)!10} Q: sedol:{(10-(sum (1 3 1 7 3 9)*{$[57<x;x-55;x-48]} each `int$x) mod 10) mod 10} And then, this is REBOL, but with an unpublished vector lib ("k.r") and therefore won't help much: sedol: func [s /local c n] [ c: map fx [either #"9" < x [x - #"A" + 10] [x - #"0"]] s mod 10 - mod (sum mul* [1 3 1 7 3 9] c) 10 10 ] Obviously you could inline this further. But I guess it's already un-REBOL-ish enough :) -- Regards, Andreas