Skip to main content
added 115 characters in body
Source Link
Alexey Golyshev
  • 9.7k
  • 2
  • 29
  • 61
 split=Split[Flatten[lowArray["NonzeroPositions"]]pos={First@#,#2==#1+1&]Last@#}&/@Split[Flatten@lowArray["NonzeroPositions"],#2-#1==1&] lowArray[[#]]&

{{1,5},{10,11},{15,20}}

 splits=lowArray[[Range@@#]]&/@split@pos//Normal 

{{1,1,1,1,1},{1,1},{1,1,1,1,1,1}}

 split=Split[Flatten[lowArray["NonzeroPositions"]],#2==#1+1&] lowArray[[#]]&/@split//Normal 
 pos={First@#,Last@#}&/@Split[Flatten@lowArray["NonzeroPositions"],#2-#1==1&] 

{{1,5},{10,11},{15,20}}

 splits=lowArray[[Range@@#]]&/@pos//Normal 

{{1,1,1,1,1},{1,1},{1,1,1,1,1,1}}

Source Link
Alexey Golyshev
  • 9.7k
  • 2
  • 29
  • 61

 split=Split[Flatten[lowArray["NonzeroPositions"]],#2==#1+1&] lowArray[[#]]&/@split//Normal