Given: contents of a text file, which may have Unix or Windows line endings, as a byte list
Task: compute the line count
Example:
bytes={65, 13, 10, 66, 67, 13, 10}
I thought Count[bytes, PatternSequence[13,10]] might do the trick, but it gives zero. Count[bytes,10|13]/2 works, if I can know that I’m getting Windows line endings.
Count[bytes, PatternSequence[13,10]] doesn’t work because Count doesn’t support sequence matching, only element matching. To do that kind of thing for Mathematica expression, one typical approach is