Semi-trivial Mathematica Question

  • Thread starter Thread starter MichalXC
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
MichalXC
Messages
39
Reaction score
0
Hi guys,

I have a long list of numbers which has only two values, e.g. {1,1,1,0,0,1,0,1,0,0,0...}.

The list is ordered as a function of time -- chronologically.

I need to see, then, how long the list stays at 1 before going to 0, and then how long the list stays at 0 before going back to 1... etc. etc. until the list terminates.

In my example above, I would expect an output like {3,2,1,1,1,3}.

How can I implement this?

Thanks.
 
Physics news on Phys.org
Woo hoo! Found my answer: the http://reference.wolfram.com/mathematica/ref/Split.html" command.
 
Last edited by a moderator: