Fill elements of current step from up to down .
for ( $ i = 0 ; $ i < $ step ; $ i ++ ) { $ curr = $ coil1 [ $ index ++ ] = $ curr + $ nflg ; if ( $ index >= $ m ) break ; } $ nflg = $ nflg * ( -1 ) ; $ step += 2 ; }