By applying Roger's idea you get:

cna =: 961 $ '0987654321'
ccd4=:cna {~([:+/@:(,.&.":)]*1+2|[EMAIL PROTECTED])@(cn&i.)
or
ccd41=: cna {~([:+/@:(,.&.":)(8$1 2)*])@(cn&i.)

B=:cn {~ ? 2e4 8 $ #cn

  (ccd"1-:[:,ccd4"1) B
1
  ts 'ccd"1 B'
1.178658 42944

  ts 'ccd4"1 B'
0.714842 44544

  ts 'ccd41"1 B'
0.665817 44608



@@i schreef:


 +/,.&.": 10 3 112 16 7
22


Dan Bron schreef:
I wrote:
 usual metrics apply:  novelty, brevity,  velocity, and parsimony.

I'm most interested in an elegant way to rephrase sum-of-the-digits:

       +/@:,@:(#.^:_1)

Can you come up with a better way?  Example:

       10 +/@:,@:(#.^:_1) 10 3 112 16 7     22

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to