It is possible to avoid any use of 10| at all:

sna  =: 841 $ '0987654321'
guard=: sna {~ 1 3 1 7 3 9 +/ .*~ sn i. ]
acs4 =: ,"1 0 guard



----- Original Message -----
From: Henry Rich <[EMAIL PROTECTED]>
Date: Friday, August 1, 2008 22:24
Subject: RE: [Jprogramming] Check digit utility
To: 'Programming forum' <[email protected]>

> That - is a bit plump:
> 
>    acs3 =. (,   10 | 9 7 9 3 7 1 +/@:* 
> ])&.(sn i. |:)
> 
> Henry Rich
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of Dan Bron
> > Sent: Friday, August 01, 2008 11:48 PM
> > To: 'Programming forum'
> > Subject: RE: [Jprogramming] Check digit utility
> > 
> > I wrote:
> > >   sn   =.  
> '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'         
> >      NB.  SEDOL numerals
> > >           acs0 =.  (,. 10 | 10 - 10 | 1 3 1 7 3 
> 9 +/@:*"1 
> > ])&.(sn&i.)  NB.  Append checksum
> > 
> > Then refined (thanks to Raul):
> > >           acs1 =.  (, 10 | 0 - 1 3 1 7 3 9 
> +/@:* ])&.(sn i. |:) 
> > 
> > One more refinement:
> > 
> >     acs2 =.  (, 10 | 1 3 1 7 3 9 
> +/@:* -)&.(sn i. |:) 
> > 
> > Though this version is a bit slower than the previous  
> acs1  
> > I prefer it.  There is no fat left to cut.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to