sgs=:[:;[:+/\&.><;.1

Dan Bron wrote:

I need running sums that obey traffic lights.
           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  ?  So far I've got:

           db0 =:  (~:&0@:[ * +)/\.&.|.
           db1 =:  ;@:(<@:(+/\);.1~ (< _1&(|.!._)))

-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

Reply via email to