join_subsequences_by_sign_of_elements

sequencetools.join_subsequences_by_sign_of_elements(sequence)

Joins subsequences in sequence by sign of elements.

Example 1. Joins lists by sign of elements:

>>> sequence = [[1, 2], [3, 4], [-5, -6, -7], [-8, -9, -10], [11, 12]]
>>> sequencetools.join_subsequences_by_sign_of_elements(sequence)
[[1, 2, 3, 4], [-5, -6, -7, -8, -9, -10], [11, 12]]

Example 2. Works with empty lists:

>>> sequence = [[1, 2], [], [], [3, 4, 5], [6, 7]]
>>> sequencetools.join_subsequences_by_sign_of_elements(sequence)
[[1, 2], [], [3, 4, 5, 6, 7]]

Example 3. Joins tuples by sign of elements:

>>> sequence = [(1, 2), (), (), (3, 4, 5), (6, 7)]
>>> sequencetools.join_subsequences_by_sign_of_elements(sequence)
[(1, 2), (), (3, 4, 5, 6, 7)]

Returns new list.