You have actually two questions, the one from the title and the question lurking behind it. The first one is answered by:
First/@ list
The second one, counting the number of runs of 1's, has been answered many times, but this solution
Total[Clip[ListCorrelate[{-1, 1}, #], {0, 1}]] + First[#] &
is about 50% faster than Leonid's solution. Note I increased the length of the test list for better timing:
largeTestList = RandomInteger[{0, 1}, {10000000}];
Count[Split[largeTestList], {1 ..}] // AbsoluteTiming
Count[Split[largeTestList][[All, 1]], 1] // AbsoluteTiming
Total[Clip[Differences@#, {0, 1}]] + First[#] &@ largeTestList // AbsoluteTiming
(Tr@Unitize@Differences@# + Tr@#[[{1, -1}]])/2 &@ largeTestList // AbsoluteTiming
Total[Clip[ListCorrelate[{-1, 1}, #], {0, 1}]] + First[#] &@
largeTestList // AbsoluteTiming
Out[680]= {3.4361965, 2498095}
Out[681]= {2.4531403, 2498095}
Out[682]= {0.2710155, 2498095}
Out[683]= {0.2530145, 2498095}
Out[684]= {0.1710097, 2498095}
After Leonid's compilation attack I was about to throw in the towel, but I spotted a possible optimization, so onwards goes the battle... [Mr.Wizard, Leonid and I should be thrown in jail for disturbing the peace on SO]
runsOf1Cbis =
Compile[{{lst, _Integer, 1}},
Module[{r = Table[0, {Length[lst] - 1}], i = 1, ctr = First[lst]},
For[i = 2, i <= Length[lst], i++,
If[lst[[i]] == 1 && lst[[i - 1]] == 0, ctr++; i++]];
ctr], CompilationTarget -> "C", RuntimeOptions -> "Speed"]
largeTestList = RandomInteger[{0, 1}, {10000000}];
Total[Clip[ListCorrelate[{-1, 1}, #], {0, 1}]] + First[#] &@
largeTestList // AbsoluteTiming
runsOf1C[largeTestList] // AbsoluteTiming
runsOf1Cbis[largeTestList] // AbsoluteTiming
Out[869]= {0.1770101, 2500910}
Out[870]= {0.0960055, 2500910}
Out[871]= {0.0810046, 2500910}
The results vary, but I get an improvement between 10 and 30%.
The optimization may be hard to spot, but it's the extra i++
if the {0,1} test succeeds. You can't have two of these in successive locations.
And, here, an optimization of Leonid's optimization of my optimization of his optimization (I hope this isn't going to drag on, or I'm going to suffer a stack overflow):
runsOf1CDitto =
Compile[{{lst, _Integer, 1}},
Module[{i = 1, ctr = First[lst]},
For[i = 2, i <= Length[lst], i++,
If[lst[[i]] == 1, If[lst[[i - 1]] == 0, ctr++];
i++]];
ctr], CompilationTarget -> "C", RuntimeOptions -> "Speed"]
largeTestList = RandomInteger[{0, 1}, {10000000}];
Total[Clip[ListCorrelate[{-1, 1}, #], {0, 1}]] + First[#] &@
largeTestList // AbsoluteTiming
runsOf1C[largeTestList] // AbsoluteTiming
runsOf1Cbis[largeTestList] // AbsoluteTiming
runsOf1CAlt[largeTestList] // AbsoluteTiming
runsOf1CDitto[largeTestList] // AbsoluteTiming
Out[907]= {0.1760101, 2501382}
Out[908]= {0.0990056, 2501382}
Out[909]= {0.0780045, 2501382}
Out[910]= {0.0670038, 2501382}
Out[911]= {0.0600034, 2501382}
Lucky for me, Leonid had a superfluous initialization in his code that could be removed.