Dan Bron wrote: > sgs 0 1 1 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 > 0 1 2 3 0 0 0 0 1 2 0 0 0 1 2 3 4 5 0 1 > > What's the most efficient way to express sgs
Here's timing for the various implementations which have been posted so far: db0 =: (~:&0@:[ * +)/\.&.|. db1 =: ;@:(<@:(+/\);.1~ (< _1&(|.!._))) rdm=: -. (] - [: >./\ *) +/\ reb=: (0:[EMAIL PROTECTED])/\.&.|. dg=:[:;[:+/\&.><;.1 v=: 1e6$0 1 1 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 time=:4 :0 '`verb ignore'=.x`] if._1<nc<'prior'do.assert(prior-:verb)y end. smoutput (5!:5<'verb'),TAB,":6!:2 'verb y' prior=:verb ,.'' ) db0`db1`rdm`reb`dg time"0 1 v db0 2.43829 db1 0.446227 rdm 0.0384559 reb 2.22763 dg 0.796831 -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
