I wrote:
> suspect there's a more concise way to express this.
Raul Miller wrote:
> (10&|@- -: 10 | 10 - 10 | ]) i: 100
Insightful. Thank you.
Here's a new version:
(, 10 | 0 - 1 3 1 7 3 9 +/@:* ])&.(sn i. |:)
It's shorter and more than twice as fast. Plus it'll work properly on a single
vector, instead of just tables:
sn =. '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' NB.
SEDOL numerals
acs0 =: (,. 10|10 - 10 | 1 3 1 7 3 9 +/@:*"1 ])&.(sn&i.)
acs1 =: (, 10 | 0 - 1 3 1 7 3 9 +/@:* ])&.(sn i. |:)
acs0 '026349' NB. Old version doesn't handle simple vector
input
04
24
64
34
44
94
acs1 '026349'
0263494
A=:sn {~ ? 4e6 6 $ #sn NB. Big input for testing
(acs0 -: acs1) A
1
ts =: 6!:2 , 7!:2@:]
%&:(10&ts)&:(,&' A')&>/ acs0`acs1 NB. New version twice as fast,
just as lean
2.33376 0.999991
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm