Sequence

class datastructuretools.Sequence(items=None)

Sequence.

>>> import abjad

Initializes sequence:

>>> abjad.Sequence([1, 2, 3, 4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression = abjad.sequence()
>>> expression([1, 2, 3, 4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])

Initializes and reverses sequence:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence.reverse()
Sequence([6, 5, 4, 3, 2, 1])
>>> expression = abjad.sequence()
>>> expression = expression.reverse()
>>> expression([1, 2, 3, 4, 5, 6])
Sequence([6, 5, 4, 3, 2, 1])

Initializes, reverses and flattens sequence:

>>> sequence = abjad.Sequence([1, 2, 3, [4, 5, [6]]])
>>> sequence = sequence.reverse()
>>> sequence = sequence.flatten()
>>> sequence
Sequence([4, 5, 6, 3, 2, 1])
>>> expression = abjad.sequence()
>>> expression = expression.reverse()
>>> expression = expression.flatten()
>>> expression([1, 2, 3, [4, 5, [6]]])
Sequence([4, 5, 6, 3, 2, 1])

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.Sequence.Sequence" [color=black, fontcolor=white, group=2, label=<<B>Sequence</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.datastructuretools.Sequence.Sequence"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

flatten([classes, depth, indices]) Flattens sequence.
group_by() Groups sequence items by value of items.
is_decreasing([strict]) Is true when sequence decreases.
is_increasing([strict]) Is true when sequence increases.
is_permutation([length]) Is true when sequence is a permutation.
is_repetition_free() Is true when sequence is repetition-free.
items Gets sequence items.
join() Join subsequences in sequence.
map([operand]) Maps operand to sequence items.
nwise([n, cyclic, wrapped]) Iterates sequence n at a time.
partition_by_counts(counts[, cyclic, …]) Partitions sequence by counts.
partition_by_ratio_of_lengths(ratio) Partitions sequence by ratio of lengths.
partition_by_ratio_of_weights(weights) Partitions sequence by ratio of weights.
partition_by_weights(weights[, cyclic, …]) Partitions sequence by weights exactly.
permute(permutation) Permutes sequence by permutation.
remove([indices, period]) Removes items at indices.
remove_repeats() Removes repeats from sequence.
repeat([n]) Repeats sequence.
repeat_to_length([length, start]) Repeats sequence to length.
repeat_to_weight(weight[, allow_total]) Repeats sequence to weight.
replace(indices, new_material) Replaces items at indices with new_material.
retain([indices, period]) Retains items at indices.
reverse([recurse]) Reverses sequence.
rotate([n]) Rotates sequence by index n.
sort([key, reverse]) Sorts sequence.
split(weights[, cyclic, overhang]) Splits sequence by weights.
sum() Sums sequence.
sum_by_sign([sign]) Sums consecutive sequence items by sign.
truncate([sum, weight]) Truncates sequence.
zip([cyclic, truncate]) Zips sequences in sequence.
__add__(argument) Adds argument to sequence.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when argument is a sequence with items equal to those of this sequence.
__format__([format_specification]) Formats sequence.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes sequence.
__len__() Gets length of sequence.
__ne__(argument) Is true when Abjad object does not equal argument.
__radd__(argument) Adds sequence to argument.
__repr__() Gets interpreter representation of sequence.

Read-only properties

Sequence.items

Gets sequence items.

Initializes items positionally:

>>> abjad.Sequence([1, 2, 3, 4, 5, 6]).items
(1, 2, 3, 4, 5, 6)

Initializes items from keyword:

>>> abjad.Sequence(items=[1, 2, 3, 4, 5, 6]).items
(1, 2, 3, 4, 5, 6)

Initializes items positionally:

>>> expression = abjad.sequence()
>>> expression([1, 2, 3, 4, 5, 6]).items
(1, 2, 3, 4, 5, 6)

Initializes items from keyword:

>>> expression = abjad.sequence()
>>> expression(items=[1, 2, 3, 4, 5, 6]).items
(1, 2, 3, 4, 5, 6)

Returns tuple.

Methods

Sequence.flatten(classes=None, depth=-1, indices=None)

Flattens sequence.

Flattens sequence:

>>> items = [1, [2, 3, [4]], 5, [6, 7, [8]]]
>>> sequence = abjad.Sequence(items=items)
>>> sequence.flatten()
Sequence([1, 2, 3, 4, 5, 6, 7, 8])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten()
>>> expression([1, [2, 3, [4]], 5, [6, 7, [8]]])
Sequence([1, 2, 3, 4, 5, 6, 7, 8])
>>> expression.get_string()
'flatten(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Flattens sequence to depth 1:

>>> items = [1, [2, 3, [4]], 5, [6, 7, [8]]]
>>> sequence = abjad.Sequence(items)
>>> sequence.flatten(depth=1)
Sequence([1, 2, 3, [4], 5, 6, 7, [8]])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten(depth=1)
>>> expression([1, [2, 3, [4]], 5, [6, 7, [8]]])
Sequence([1, 2, 3, [4], 5, 6, 7, [8]])
>>> expression.get_string()
'flatten(J, depth=1)'
>>> markup = expression.get_markup()
>>> show(markup) 

Flattens sequence to depth 2:

>>> items = [1, [2, 3, [4]], 5, [6, 7, [8]]]
>>> sequence = abjad.Sequence(items)
>>> sequence.flatten(depth=2)
Sequence([1, 2, 3, 4, 5, 6, 7, 8])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten(depth=2)
>>> expression([1, [2, 3, [4]], 5, [6, 7, [8]]])
Sequence([1, 2, 3, 4, 5, 6, 7, 8])
>>> expression.get_string()
'flatten(J, depth=2)'
>>> markup = expression.get_markup()
>>> show(markup) 

Flattens sequence at indices:

>>> items = [1, [2, 3, [4]], 5, [6, 7, [8]]]
>>> sequence = abjad.Sequence(items)
>>> sequence.flatten(indices=[3])
Sequence([1, [2, 3, [4]], 5, 6, 7, 8])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten(indices=[3])
>>> expression([1, [2, 3, [4]], 5, [6, 7, [8]]])
Sequence([1, [2, 3, [4]], 5, 6, 7, 8])
>>> expression.get_string()
'flatten(J, indices=[3])'
>>> markup = expression.get_markup()
>>> show(markup) 

Flattens sequence at negative indices:

>>> items = [1, [2, 3, [4]], 5, [6, 7, [8]]]
>>> sequence = abjad.Sequence(items)
>>> sequence.flatten(indices=[-1])
Sequence([1, [2, 3, [4]], 5, 6, 7, 8])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten(indices=[-1])
>>> expression([1, [2, 3, [4]], 5, [6, 7, [8]]])
Sequence([1, [2, 3, [4]], 5, 6, 7, 8])
>>> expression.get_string()
'flatten(J, indices=[-1])'
>>> markup = expression.get_markup()
>>> show(markup) 

Flattens tuples in sequence only:

>>> items = ['ab', 'cd', ('ef', 'gh'), ('ij', 'kl')]
>>> sequence = abjad.Sequence(items=items)
>>> sequence.flatten(classes=(tuple,))
Sequence(['ab', 'cd', 'ef', 'gh', 'ij', 'kl'])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.flatten(classes=(tuple,))
>>> expression(['ab', 'cd', ('ef', 'gh'), ('ij', 'kl')])
Sequence(['ab', 'cd', 'ef', 'gh', 'ij', 'kl'])
>>> expression.get_string()
'flatten(J, classes=(tuple,))'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.group_by()

Groups sequence items by value of items.

>>> items = [0, 0, -1, -1, 2, 3, -5, 1, 1, 5, -5]
>>> sequence = abjad.sequence(items)
>>> for item in sequence.group_by():
...     item
...
Sequence([0, 0])
Sequence([-1, -1])
Sequence([2])
Sequence([3])
Sequence([-5])
Sequence([1, 1])
Sequence([5])
Sequence([-5])

Returns nested sequence.

Sequence.is_decreasing(strict=True)

Is true when sequence decreases.

Is true when sequence is strictly decreasing:

>>> abjad.Sequence([5, 4, 3, 2, 1, 0]).is_decreasing(strict=True)
True
>>> abjad.Sequence([3, 3, 3, 2, 1, 0]).is_decreasing(strict=True)
False
>>> abjad.Sequence([3, 3, 3, 3, 3, 3]).is_decreasing(strict=True)
False
>>> abjad.Sequence().is_decreasing(strict=True)
True

Is true when sequence decreases monotonically:

>>> abjad.Sequence([5, 4, 3, 2, 1, 0]).is_decreasing(strict=False)
True
>>> abjad.Sequence([3, 3, 3, 2, 1, 0]).is_decreasing(strict=False)
True
>>> abjad.Sequence([3, 3, 3, 3, 3, 3]).is_decreasing(strict=False)
True
>>> abjad.Sequence().is_decreasing(strict=False)
True

Returns true or false.

Sequence.is_increasing(strict=True)

Is true when sequence increases.

Is true when sequence is strictly increasing:

>>> abjad.Sequence([0, 1, 2, 3, 4, 5]).is_increasing(strict=True)
True
>>> abjad.Sequence([0, 1, 2, 3, 3, 3]).is_increasing(strict=True)
False
>>> abjad.Sequence([3, 3, 3, 3, 3, 3]).is_increasing(strict=True)
False
>>> abjad.Sequence().is_increasing(strict=True)
True

Is true when sequence increases monotonically:

>>> abjad.Sequence([0, 1, 2, 3, 4, 5]).is_increasing(strict=False)
True
>>> abjad.Sequence([0, 1, 2, 3, 3, 3]).is_increasing(strict=False)
True
>>> abjad.Sequence([3, 3, 3, 3, 3, 3]).is_increasing(strict=False)
True
>>> abjad.Sequence().is_increasing(strict=False)
True

Returns true or false.

Sequence.is_permutation(length=None)

Is true when sequence is a permutation.

Is true when sequence is a permutation:

>>> abjad.Sequence([4, 5, 0, 3, 2, 1]).is_permutation()
True

Is false when sequence is not a permutation:

>>> abjad.Sequence([1, 1, 5, 3, 2, 1]).is_permutation()
False

Returns true or false.

Sequence.is_repetition_free()

Is true when sequence is repetition-free.

Is true when sequence is repetition-free:

>>> abjad.Sequence([0, 1, 2, 6, 7, 8]).is_repetition_free()
True

Is true when sequence is empty:

>>> abjad.Sequence().is_repetition_free()
True

Is false when sequence contains repetitions:

>>> abjad.Sequence([0, 1, 2, 2, 7, 8]).is_repetition_free()
False

Returns true or false.

Sequence.join()

Join subsequences in sequence.

>>> items = [(1, 2, 3), (), (4, 5), (), (6,)]
>>> sequence = abjad.sequence(items=items)
>>> sequence
Sequence([(1, 2, 3), (), (4, 5), (), (6,)])
>>> sequence.join()
Sequence([(1, 2, 3, 4, 5, 6)])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.split([10], cyclic=True)
>>> expression = expression.join()
>>> expression(range(1, 11))
Sequence([Sequence([1, 2, 3, 4, 5, 5, 1, 7, 2, 6, 4, 5, 5])])
>>> expression.get_string()
'join(split(J, <10>))'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.map(operand=None)

Maps operand to sequence items.

Partitions sequence and sums parts:

>>> sequence = abjad.Sequence(range(1, 10+1))
>>> sequence = sequence.partition_by_counts(
...     [3],
...     cyclic=True,
...     )
>>> sequence = sequence.map(sum)
>>> sequence
Sequence([6, 15, 24])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=True,
...     )
>>> expression = expression.map(abjad.sequence().sum())
>>> expression(range(1, 10+1))
Sequence([6, 15, 24])
>>> expression.get_string()
'sum(X) /@ partition(J, <3>)'
>>> markup = expression.get_markup()
>>> show(markup) 

Maps identity:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence.map()
Sequence([1, 2, 3, 4, 5, 6])

Returns new sequence.

Sequence.nwise(n=2, cyclic=False, wrapped=False)

Iterates sequence n at a time.

Iterates iterable by pairs:

>>> sequence = abjad.Sequence(range(10))
>>> for item in sequence.nwise():
...     item
...
Sequence([0, 1])
Sequence([1, 2])
Sequence([2, 3])
Sequence([3, 4])
Sequence([4, 5])
Sequence([5, 6])
Sequence([6, 7])
Sequence([7, 8])
Sequence([8, 9])

Iterates iterable by triples:

>>> sequence = abjad.Sequence(range(10))
>>> for item in sequence.nwise(n=3):
...     item
...
Sequence([0, 1, 2])
Sequence([1, 2, 3])
Sequence([2, 3, 4])
Sequence([3, 4, 5])
Sequence([4, 5, 6])
Sequence([5, 6, 7])
Sequence([6, 7, 8])
Sequence([7, 8, 9])

Iterates iterable by pairs. Wraps around at end:

>>> sequence = abjad.Sequence(range(10))
>>> for item in sequence.nwise(n=2, wrapped=True):
...     item
...
Sequence([0, 1])
Sequence([1, 2])
Sequence([2, 3])
Sequence([3, 4])
Sequence([4, 5])
Sequence([5, 6])
Sequence([6, 7])
Sequence([7, 8])
Sequence([8, 9])
Sequence([9, 0])

Iterates iterable by triples. Wraps around at end:

>>> sequence = abjad.Sequence(range(10))
>>> for item in sequence.nwise(n=3, wrapped=True):
...     item
...
Sequence([0, 1, 2])
Sequence([1, 2, 3])
Sequence([2, 3, 4])
Sequence([3, 4, 5])
Sequence([4, 5, 6])
Sequence([5, 6, 7])
Sequence([6, 7, 8])
Sequence([7, 8, 9])
Sequence([8, 9, 0])
Sequence([9, 0, 1])

Iterates iterable by pairs. Cycles indefinitely:

>>> sequence = abjad.Sequence(range(10))
>>> pairs = sequence.nwise(n=2, cyclic=True)
>>> for _ in range(15):
...     next(pairs)
...
Sequence([0, 1])
Sequence([1, 2])
Sequence([2, 3])
Sequence([3, 4])
Sequence([4, 5])
Sequence([5, 6])
Sequence([6, 7])
Sequence([7, 8])
Sequence([8, 9])
Sequence([9, 0])
Sequence([0, 1])
Sequence([1, 2])
Sequence([2, 3])
Sequence([3, 4])
Sequence([4, 5])

Returns infinite generator.

Iterates iterable by triples. Cycles indefinitely:

>>> sequence = abjad.Sequence(range(10))
>>> triples = sequence.nwise(n=3, cyclic=True)
>>> for _ in range(15):
...     next(triples)
...
Sequence([0, 1, 2])
Sequence([1, 2, 3])
Sequence([2, 3, 4])
Sequence([3, 4, 5])
Sequence([4, 5, 6])
Sequence([5, 6, 7])
Sequence([6, 7, 8])
Sequence([7, 8, 9])
Sequence([8, 9, 0])
Sequence([9, 0, 1])
Sequence([0, 1, 2])
Sequence([1, 2, 3])
Sequence([2, 3, 4])
Sequence([3, 4, 5])
Sequence([4, 5, 6])

Returns infinite generator.

Iterates items one at a time:

>>> sequence = abjad.Sequence(range(10))
>>> for item in sequence.nwise(n=1):
...     item
...
Sequence([0])
Sequence([1])
Sequence([2])
Sequence([3])
Sequence([4])
Sequence([5])
Sequence([6])
Sequence([7])
Sequence([8])
Sequence([9])

Ignores wrapped when cyclic is true.

Returns generator.

Sequence.partition_by_counts(counts, cyclic=False, overhang=False, reversed_=False)

Partitions sequence by counts.

Partitions sequence once by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> sequence = sequence.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     )
>>> sequence
Sequence([Sequence([0, 1, 2])])
>>> for part in sequence:
...     part
... 
Sequence([0, 1, 2])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2])
>>> expression.get_string()
'partition(J, [3])'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence once by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=False,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=False,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
>>> expression.get_string()
'partition(J, [4, 3])'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence cyclically by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5])
Sequence([6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5])
Sequence([6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14])
>>> expression.get_string()
'partition(J, <3>)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence cyclically by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=False,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10])
Sequence([11, 12, 13])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=False,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10])
Sequence([11, 12, 13])
>>> expression.get_string()
'partition(J, <4, 3>)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence once by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
>>> expression.get_string()
'partition(J, [3]+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence once by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10, 11, 12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10, 11, 12, 13, 14, 15])
>>> expression.get_string()
'partition(J, [4, 3]+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence cyclically by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5])
Sequence([6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14])
Sequence([15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5])
Sequence([6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14])
Sequence([15])
>>> expression.get_string()
'partition(J, <3>+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence cyclically by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10])
Sequence([11, 12, 13])
Sequence([14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9, 10])
Sequence([11, 12, 13])
Sequence([14, 15])
>>> expression.get_string()
'partition(J, <4, 3>+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence once by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([13, 14, 15])
>>> expression.get_string()
'partition(J, R[3])'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence once by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression.get_string()
'partition(J, R[4, 3])'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence cyclically by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9])
Sequence([10, 11, 12])
Sequence([13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9])
Sequence([10, 11, 12])
Sequence([13, 14, 15])
>>> expression.get_string()
'partition(J, R<3>)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence cyclically by counts without overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=False,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression.get_string()
'partition(J, R<4, 3>)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence once by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
Sequence([13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
Sequence([13, 14, 15])
>>> expression.get_string()
'partition(J, R[3]+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence once by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=False,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression.get_string()
'partition(J, R[4, 3]+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence cyclically by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0])
Sequence([1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9])
Sequence([10, 11, 12])
Sequence([13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in expression(range(16)):
...     part
... 
Sequence([0])
Sequence([1, 2, 3])
Sequence([4, 5, 6])
Sequence([7, 8, 9])
Sequence([10, 11, 12])
Sequence([13, 14, 15])
>>> expression.get_string()
'partition(J, R<3>+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverse-partitions sequence cyclically by counts with overhang:

>>> sequence = abjad.Sequence(range(16))
>>> parts = sequence.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1])
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [4, 3],
...     cyclic=True,
...     overhang=True,
...     reversed_=True,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1])
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8])
Sequence([9, 10, 11])
Sequence([12, 13, 14, 15])
>>> expression.get_string()
'partition(J, R<4, 3>+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence once by counts and asserts that sequence partitions exactly (with no overhang):

>>> sequence = abjad.Sequence(range(10))
>>> parts = sequence.partition_by_counts(
...     [2, 3, 5],
...     cyclic=False,
...     overhang=Exact,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1])
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8, 9])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [2, 3, 5],
...     cyclic=False,
...     overhang=Exact,
...     )
>>> for part in expression(range(10)):
...     part
... 
Sequence([0, 1])
Sequence([2, 3, 4])
Sequence([5, 6, 7, 8, 9])
>>> expression.get_string()
'partition(J, [2, 3, 5]!)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence cyclically by counts and asserts that sequence partitions exactly Exact partitioning means partitioning with no overhang:

>>> sequence = abjad.Sequence(range(10))
>>> parts = sequence.partition_by_counts(
...     [2],
...     cyclic=True,
...     overhang=Exact,
...     )
>>> for part in parts:
...     part
... 
Sequence([0, 1])
Sequence([2, 3])
Sequence([4, 5])
Sequence([6, 7])
Sequence([8, 9])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [2],
...     cyclic=True,
...     overhang=Exact,
...     )
>>> for part in expression(range(10)):
...     part
... 
Sequence([0, 1])
Sequence([2, 3])
Sequence([4, 5])
Sequence([6, 7])
Sequence([8, 9])
>>> expression.get_string()
'partition(J, <2>!)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions string:

>>> sequence = abjad.Sequence('some text')
>>> parts = sequence.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in parts:
...     part
... 
Sequence(['s', 'o', 'm'])
Sequence(['e', ' ', 't', 'e', 'x', 't'])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
>>> for part in expression('some text'):
...     part
... 
Sequence(['s', 'o', 'm'])
Sequence(['e', ' ', 't', 'e', 'x', 't'])
>>> expression.get_string()
'partition(J, [3]+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns nested sequence.

Sequence.partition_by_ratio_of_lengths(ratio)

Partitions sequence by ratio of lengths.

Partitions sequence by 1:1:1 ratio:

>>> numbers = abjad.Sequence(range(10))
>>> ratio = abjad.Ratio((1, 1, 1))
>>> for part in numbers.partition_by_ratio_of_lengths(ratio):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5, 6])
Sequence([7, 8, 9])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> ratio = abjad.Ratio((1, 1, 1))
>>> expression = expression.partition_by_ratio_of_lengths(ratio)
>>> for part in expression(range(10)):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4, 5, 6])
Sequence([7, 8, 9])
>>> expression.get_string()
'partition(J, 1:1:1)'
>>> markup = expression.get_markup()
>>> show(markup) 

Partitions sequence by 1:1:2 ratio:

>>> numbers = abjad.Sequence(range(10))
>>> ratio = abjad.Ratio((1, 1, 2))
>>> for part in numbers.partition_by_ratio_of_lengths(ratio):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4])
Sequence([5, 6, 7, 8, 9])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> ratio = abjad.Ratio((1, 1, 2))
>>> expression = expression.partition_by_ratio_of_lengths(ratio)
>>> for part in expression(range(10)):
...     part
... 
Sequence([0, 1, 2])
Sequence([3, 4])
Sequence([5, 6, 7, 8, 9])
>>> expression.get_string()
'partition(J, 1:1:2)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns a sequence of sequences.

Sequence.partition_by_ratio_of_weights(weights)

Partitions sequence by ratio of weights.

>>> ratio = abjad.Ratio([1, 1, 1])
>>> sequence = abjad.Sequence(10 * [1])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1])
Sequence([1, 1, 1, 1])
Sequence([1, 1, 1])
>>> ratio = abjad.Ratio([1, 1, 1, 1])
>>> sequence = abjad.Sequence(10 * [1])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1])
Sequence([1, 1])
Sequence([1, 1, 1])
Sequence([1, 1])
>>> ratio = abjad.Ratio([2, 2, 3])
>>> sequence = abjad.Sequence(10 * [1])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1])
Sequence([1, 1, 1])
Sequence([1, 1, 1, 1])
>>> ratio = abjad.Ratio([3, 2, 2])
>>> sequence = abjad.Sequence(10 * [1])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1, 1])
Sequence([1, 1, 1])
Sequence([1, 1, 1])
>>> ratio = abjad.Ratio([1, 1])
>>> items = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]
>>> sequence = abjad.Sequence(items)
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1, 1, 1, 1, 2, 2])
Sequence([2, 2, 2, 2])
>>> ratio = abjad.Ratio([1, 1, 1])
>>> items = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]
>>> sequence = abjad.Sequence(items)
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([1, 1, 1, 1, 1, 1])
Sequence([2, 2, 2])
Sequence([2, 2, 2])
>>> ratio = abjad.Ratio([1, 1, 1])
>>> sequence = abjad.Sequence([5, 5])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([5])
Sequence([5])
Sequence([])
>>> ratio = abjad.Ratio([1, 1, 1, 1])
>>> sequence = abjad.Sequence([5, 5])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([5])
Sequence([])
Sequence([5])
Sequence([])
>>> ratio = abjad.Ratio([2, 2, 3])
>>> sequence = abjad.Sequence([5, 5])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([5])
Sequence([5])
Sequence([])
>>> ratio = abjad.Ratio([3, 2, 2])
>>> sequence = abjad.Sequence([5, 5])
>>> sequence = sequence.partition_by_ratio_of_weights(ratio)
>>> for item in sequence:
...     item
...
Sequence([5])
Sequence([5])
Sequence([])

Rounded weight-proportions of sequences returned equal to rounded weights.

Returns nested sequence.

Sequence.partition_by_weights(weights, cyclic=False, overhang=False, allow_part_weights=Exact)

Partitions sequence by weights exactly.

>>> sequence = abjad.Sequence([3, 3, 3, 3, 4, 4, 4, 4, 5])

Partitions sequence once by weights with overhang:

>>> for item in sequence.partition_by_weights(
...     [3, 9],
...     cyclic=False,
...     overhang=False,
...     ):
...     item
...
Sequence([3])
Sequence([3, 3, 3])

Partitions sequence once by weights. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [3, 9],
...     cyclic=False,
...     overhang=True,
...     ):
...     item
...
Sequence([3])
Sequence([3, 3, 3])
Sequence([4, 4, 4, 4, 5])

Partitions sequence cyclically by weights:

>>> for item in sequence.partition_by_weights(
...     [12],
...     cyclic=True,
...     overhang=False,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4, 4, 4])

Partitions sequence cyclically by weights. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [12],
...     cyclic=True,
...     overhang=True,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4, 4, 4])
Sequence([4, 5])
>>> sequence = abjad.sequence([3, 3, 3, 3, 4, 4, 4, 4, 5, 5])

Partitions sequence once by weights. Allows part weights to be just less than specified:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=False,
...     overhang=False,
...     allow_part_weights=Less,
...     ):
...     item
...
Sequence([3, 3, 3])
Sequence([3])

Partitions sequence once by weights. Allows part weights to be just less than specified. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=False,
...     overhang=True,
...     allow_part_weights=Less,
...     ):
...     item
...
Sequence([3, 3, 3])
Sequence([3])
Sequence([4, 4, 4, 4, 5, 5])

Partitions sequence cyclically by weights. Allows part weights to be just less than specified:

>>> for item in sequence.partition_by_weights(
...     [10, 5],
...     cyclic=True,
...     overhang=False,
...     allow_part_weights=Less,
...     ):
...     item
...
Sequence([3, 3, 3])
Sequence([3])
Sequence([4, 4])
Sequence([4])
Sequence([4, 5])
Sequence([5])

Partitions sequence cyclically by weights. Allows part weights to be just less than specified. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [10, 5],
...     cyclic=True,
...     overhang=True,
...     allow_part_weights=Less,
...     ):
...     item
...
Sequence([3, 3, 3])
Sequence([3])
Sequence([4, 4])
Sequence([4])
Sequence([4, 5])
Sequence([5])
>>> sequence = abjad.Sequence([3, 3, 3, 3, 4, 4, 4, 4, 5, 5])

Partitions sequence once by weights. Allow part weights to be just more than specified:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=False,
...     overhang=False,
...     allow_part_weights=More,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4])

Partitions sequence once by weights. Allows part weights to be just more than specified. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=False,
...     overhang=True,
...     allow_part_weights=More,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4])
Sequence([4, 4, 4, 5, 5])

Partitions sequence cyclically by weights. Allows part weights to be just more than specified:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=True,
...     overhang=False,
...     allow_part_weights=More,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4])
Sequence([4, 4, 4])
Sequence([5])

Partitions sequence cyclically by weights. Allows part weights to be just more than specified. Allows overhang:

>>> for item in sequence.partition_by_weights(
...     [10, 4],
...     cyclic=True,
...     overhang=True,
...     allow_part_weights=More,
...     ):
...     item
...
Sequence([3, 3, 3, 3])
Sequence([4])
Sequence([4, 4, 4])
Sequence([5])
Sequence([5])

Returns nested sequence.

Sequence.permute(permutation)

Permutes sequence by permutation.

>>> sequence = abjad.sequence([10, 11, 12, 13, 14, 15])
>>> sequence.permute([5, 4, 0, 1, 2, 3])
Sequence([15, 14, 10, 11, 12, 13])
>>> sequence = abjad.sequence([11, 12, 13, 14])
>>> sequence.permute([1, 0, 3, 2])
Sequence([12, 11, 14, 13])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.permute([1, 0, 3, 2])
>>> expression([11, 12, 13, 14])
Sequence([12, 11, 14, 13])
>>> expression.get_string()
'permute(J, permutation=[1, 0, 3, 2])'
>>> markup = expression.get_markup()
>>> show(markup) 

Raises exception when lengths do not match:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence.permute([3, 0, 1, 2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joberholtzer/Abjad/abjad/abjad/tools/datastructuretools/Sequence.py", line 4235, in permute
    raise ValueError(message)
ValueError: permutation Sequence([3, 0, 1, 2]) must match length of sequence Sequence([1, 2, 3, 4, 5, 6]).

Returns new sequence.

Sequence.remove(indices=None, period=None)

Removes items at indices.

>>> sequence = abjad.Sequence(range(15))
>>> sequence.remove()
Sequence([])
>>> sequence.remove(indices=[2, 3])
Sequence([0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

Removes elements and indices -2 and -3:

>>> sequence.remove(indices=[-2, -3])
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14])
>>> sequence.remove(indices=[2, 3], period=4)
Sequence([0, 1, 4, 5, 8, 9, 12, 13])
>>> sequence.remove(indices=[-2, -3], period=4)
Sequence([2, 3, 6, 7, 10, 11, 14])
>>> sequence.remove(indices=[])
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
>>> sequence.remove(indices=[97, 98, 99])
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

Removes no elements:

>>> sequence.remove(indices=[-97, -98, -99])
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

Returns new sequence.

Sequence.remove_repeats()

Removes repeats from sequence.

>>> items = [31, 31, 35, 35, 31, 31, 31, 31, 35]
>>> sequence = abjad.Sequence(items)
>>> sequence.remove_repeats()
Sequence([31, 35, 31, 35])

Returns new sequence.

Sequence.repeat(n=1)

Repeats sequence.

>>> abjad.Sequence([1, 2, 3]).repeat(n=0)
Sequence([])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.repeat(n=0)
>>> expression([1, 2, 3])
Sequence([])
>>> expression.get_string()
'repeat(J, n=0)'
>>> markup = expression.get_markup()
>>> show(markup) 
>>> abjad.Sequence([1, 2, 3]).repeat(n=1)
Sequence([Sequence([1, 2, 3])])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.repeat(n=1)
>>> expression([1, 2, 3])
Sequence([Sequence([1, 2, 3])])
>>> expression.get_string()
'repeat(J)'
>>> markup = expression.get_markup()
>>> show(markup) 
>>> abjad.Sequence([1, 2, 3]).repeat(n=2)
Sequence([Sequence([1, 2, 3]), Sequence([1, 2, 3])])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.repeat(n=2)
>>> expression([1, 2, 3])
Sequence([Sequence([1, 2, 3]), Sequence([1, 2, 3])])
>>> expression.get_string()
'repeat(J, n=2)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns sequence of sequences.

Sequence.repeat_to_length(length=None, start=0)

Repeats sequence to length.

Repeats list to length 11:

>>> abjad.Sequence(range(5)).repeat_to_length(11)
Sequence([0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0])
>>> abjad.Sequence(range(5)).repeat_to_length(11, start=2)
Sequence([2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2])
>>> sequence = abjad.Sequence([0, -1, -2, -3, -4])
>>> sequence.repeat_to_length(11)
Sequence([0, -1, -2, -3, -4, 0, -1, -2, -3, -4, 0])
>>> sequence.repeat_to_length(0)
Sequence([])
>>> abjad.Sequence([1, 2, 3]).repeat_to_length(10, start=100)
Sequence([2, 3, 1, 2, 3, 1, 2, 3, 1, 2])

Returns new sequence.

Sequence.repeat_to_weight(weight, allow_total=Exact)

Repeats sequence to weight.

Repeats sequence to weight of 23 exactly:

>>> abjad.Sequence([5, -5, -5]).repeat_to_weight(23)
Sequence([5, -5, -5, 5, -3])

Repeats sequence to weight of 23 more:

>>> sequence = abjad.Sequence([5, -5, -5])
>>> sequence.repeat_to_weight(23, allow_total=More)
Sequence([5, -5, -5, 5, -5])

Repeats sequence to weight of 23 or less:

>>> sequence = abjad.Sequence([5, -5, -5])
>>> sequence.repeat_to_weight(23, allow_total=Less)
Sequence([5, -5, -5, 5])
>>> items = [abjad.NonreducedFraction(3, 16)]
>>> sequence = abjad.Sequence(items)
>>> weight = abjad.NonreducedFraction(5, 4)
>>> sequence = sequence.repeat_to_weight(weight)
>>> sum(sequence)
NonreducedFraction(20, 16)
>>> [_.pair for _ in sequence]
[(3, 16), (3, 16), (3, 16), (3, 16), (3, 16), (3, 16), (2, 16)]

Returns new sequence.

Sequence.replace(indices, new_material)

Replaces items at indices with new_material.

Replaces items at indices 0, 2, 4, 6:

>>> sequence = abjad.Sequence(range(16))
>>> sequence.replace(
...     ([0], 2),
...     (['A', 'B', 'C', 'D'], None),
...     )
Sequence(['A', 1, 'B', 3, 'C', 5, 'D', 7, 8, 9, 10, 11, 12, 13, 14, 15])

Replaces elements at indices 0, 1, 8, 13:

>>> sequence = abjad.Sequence(range(16))
>>> sequence.replace(
...     ([0, 1, 8, 13], None),
...     (['A', 'B', 'C', 'D'], None),
...     )
Sequence(['A', 'B', 2, 3, 4, 5, 6, 7, 'C', 9, 10, 11, 12, 'D', 14, 15])

Replaces every item at even index:

>>> sequence = abjad.Sequence(range(16))
>>> sequence.replace(
...     ([0], 2),
...     (['*'], 1),
...     )
Sequence(['*', 1, '*', 3, '*', 5, '*', 7, '*', 9, '*', 11, '*', 13, '*', 15])

Replaces every element at an index congruent to 0 (mod 6) with 'A'; replaces every element at an index congruent to 2 (mod 6) with 'B':

>>> sequence = abjad.Sequence(range(16))
>>> sequence.replace(
...     ([0], 2),
...     (['A', 'B'], 3),
...     )
Sequence(['A', 1, 'B', 3, 4, 5, 'A', 7, 'B', 9, 10, 11, 'A', 13, 'B', 15])

Returns new sequence.

Sequence.retain(indices=None, period=None)

Retains items at indices.

>>> sequence = abjad.Sequence(range(10))
>>> sequence.retain()
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> sequence.retain(indices=[2, 3])
Sequence([2, 3])
>>> sequence.retain(indices=[-2, -3])
Sequence([7, 8])
>>> sequence.retain(indices=[2, 3], period=4)
Sequence([2, 3, 6, 7])
>>> sequence.retain(indices=[-2, -3], period=4)
Sequence([0, 3, 4, 7, 8])
>>> sequence.retain(indices=[])
Sequence([])
>>> sequence.retain(indices=[97, 98, 99])
Sequence([])
>>> sequence.retain(indices=[-97, -98, -99])
Sequence([])

Returns new sequence.

Sequence.reverse(recurse=False)

Reverses sequence.

Reverses sequence:

>>> sequence = abjad.Sequence([[1, 2], 3, [4, 5]])
>>> sequence.reverse()
Sequence([[4, 5], 3, [1, 2]])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.reverse()
>>> expression([[1, 2], 3, [4, 5]])
Sequence([[4, 5], 3, [1, 2]])
>>> expression.get_string()
'R(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverses recursively:

>>> segment_1 = abjad.PitchClassSegment([1, 2])
>>> pitch = abjad.NumberedPitch(3)
>>> segment_2 = abjad.PitchClassSegment([4, 5])
>>> sequence = abjad.Sequence([segment_1, pitch, segment_2])
>>> for item in sequence.reverse(recurse=True):
...     item
...
PitchClassSegment([5, 4])
NumberedPitch(3)
PitchClassSegment([2, 1])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.reverse(recurse=True)
>>> for item in expression([segment_1, pitch, segment_2]):
...     item
...
PitchClassSegment([5, 4])
NumberedPitch(3)
PitchClassSegment([2, 1])
>>> expression.get_string()
'R*(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.rotate(n=0)

Rotates sequence by index n.

Rotates sequence to the right:

>>> sequence = abjad.Sequence(range(10))
>>> sequence.rotate(n=4)
Sequence([6, 7, 8, 9, 0, 1, 2, 3, 4, 5])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.rotate(n=4)
>>> expression(range(10))
Sequence([6, 7, 8, 9, 0, 1, 2, 3, 4, 5])
>>> expression.get_string()
'r4(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Rotates sequence to the left:

>>> sequence = abjad.Sequence(range(10))
>>> sequence.rotate(n=-3)
Sequence([3, 4, 5, 6, 7, 8, 9, 0, 1, 2])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.rotate(n=-3)
>>> expression(range(10))
Sequence([3, 4, 5, 6, 7, 8, 9, 0, 1, 2])
>>> expression.get_string()
'r-3(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Rotates sequence neither to the right nor the left:

>>> sequence = abjad.Sequence(range(10))
>>> sequence.rotate(n=0)
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.rotate(n=0)
>>> expression(range(10))
Sequence([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> expression.get_string()
'r0(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.sort(key=None, reverse=False)

Sorts sequence.

>>> sequence = abjad.Sequence([3, 2, 5, 4, 1, 6])
>>> sequence.sort()
Sequence([1, 2, 3, 4, 5, 6])
>>> sequence
Sequence([3, 2, 5, 4, 1, 6])

Returns new sequence.

Sequence.split(weights, cyclic=False, overhang=False)

Splits sequence by weights.

Splits sequence cyclically by weights with overhang:

>>> sequence = abjad.Sequence([10, -10, 10, -10])
>>> for part in sequence.split(
...     (3, 15, 3),
...     cyclic=True,
...     overhang=True,
...     ):
...     part
...
Sequence([3])
Sequence([7, -8])
Sequence([-2, 1])
Sequence([3])
Sequence([6, -9])
Sequence([-1])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.split(
...     (3, 15, 3),
...     cyclic=True,
...     overhang=True,
...     )
>>> for part in expression([10, -10, 10, -10]):
...     part
...
Sequence([3])
Sequence([7, -8])
Sequence([-2, 1])
Sequence([3])
Sequence([6, -9])
Sequence([-1])
>>> expression.get_string()
'split(J, <3, 15, 3>+)'
>>> markup = expression.get_markup()
>>> show(markup) 

Splits sequence once by weights with overhang:

>>> for part in sequence.split(
...     (3, 15, 3),
...     cyclic=False,
...     overhang=True,
...     ):
...     part
...
Sequence([3])
Sequence([7, -8])
Sequence([-2, 1])
Sequence([9, -10])

Splits sequence once by weights without overhang:

>>> for part in sequence.split(
...     (3, 15, 3),
...     cyclic=False,
...     overhang=False,
...     ):
...     part
...
Sequence([3])
Sequence([7, -8])
Sequence([-2, 1])

Returns new sequence.

Sequence.sum()

Sums sequence.

Sums sequence of positive numbers:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> sequence.sum()
55
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.sum()
>>> expression([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
55
>>> expression.get_string()
'sum(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Sum sequence of numbers with mixed signs:

>>> sequence = abjad.Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
>>> sequence.sum()
5
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.sum()
>>> expression([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
5
>>> expression.get_string()
'sum(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Sums sequence and wraps result in new sequence:

>>> sequence = abjad.Sequence(range(1, 10+1))
>>> result = sequence.sum()
>>> sequence = abjad.Sequence(result)
>>> sequence
Sequence([55])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression.sum()
>>> expression = expression.sequence()
>>> expression(range(1, 10+1))
Sequence([55])
>>> expression.get_string()
'sum(J)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.sum_by_sign(sign=(-1, 0, 1))

Sums consecutive sequence items by sign.

>>> items = [0, 0, -1, -1, 2, 3, -5, 1, 2, 5, -5, -6]
>>> sequence = abjad.Sequence(items)
>>> sequence.sum_by_sign()
Sequence([0, -2, 5, -5, 8, -11])
>>> sequence.sum_by_sign(sign=[-1])
Sequence([0, 0, -2, 2, 3, -5, 1, 2, 5, -11])
>>> sequence.sum_by_sign(sign=[0])
Sequence([0, -1, -1, 2, 3, -5, 1, 2, 5, -5, -6])
>>> sequence.sum_by_sign(sign=[1])
Sequence([0, 0, -1, -1, 5, -5, 8, -5, -6])
>>> sequence.sum_by_sign(sign=[-1, 0])
Sequence([0, -2, 2, 3, -5, 1, 2, 5, -11])
>>> sequence.sum_by_sign(sign=[-1, 1])
Sequence([0, 0, -2, 5, -5, 8, -11])
>>> sequence.sum_by_sign(sign=[0, 1])
Sequence([0, -1, -1, 5, -5, 8, -5, -6])
>>> sequence.sum_by_sign(sign=[-1, 0, 1])
Sequence([0, -2, 5, -5, 8, -11])

Sumsn consecutive negative elements when -1 in sign.

Sums consecutive zero-valued elements when 0 in sign.

Sums consecutive positive elements when 1 in sign.

Returns new sequence.

Sequence.truncate(sum=None, weight=None)

Truncates sequence.

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

Truncates sequence to weights ranging from 1 to 10:

>>> for weight in range(1, 11):
...     result = sequence.truncate(weight=weight)
...     print(weight, result)
...
1 Sequence([-1])
2 Sequence([-1, 1])
3 Sequence([-1, 2])
4 Sequence([-1, 2, -1])
5 Sequence([-1, 2, -2])
6 Sequence([-1, 2, -3])
7 Sequence([-1, 2, -3, 1])
8 Sequence([-1, 2, -3, 2])
9 Sequence([-1, 2, -3, 3])
10 Sequence([-1, 2, -3, 4])

Truncates sequence to sums ranging from 1 to 10:

>>> for sum_ in range(1, 11):
...     result = sequence.truncate(sum=sum_)
...     print(sum_, result)
...
1 Sequence([-1, 2])
2 Sequence([-1, 2, -3, 4])
3 Sequence([-1, 2, -3, 4, -5, 6])
4 Sequence([-1, 2, -3, 4, -5, 6, -7, 8])
5 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
6 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
7 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
8 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
9 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])
10 Sequence([-1, 2, -3, 4, -5, 6, -7, 8, -9, 10])

Truncates sequence to zero weight:

>>> sequence.truncate(weight=0)
Sequence([])

Truncates sequence to zero sum:

>>> sequence.truncate(sum=0)
Sequence([])

Ignores sum when weight and sum are both set.

Raises value error on negative sum.

Returns new sequence.

Sequence.zip(cyclic=False, truncate=True)

Zips sequences in sequence.

Zips cyclically:

>>> sequence = abjad.Sequence([[1, 2, 3], ['a', 'b']])
>>> for item in sequence.zip(cyclic=True):
...     item
...
Sequence([1, 'a'])
Sequence([2, 'b'])
Sequence([3, 'a'])
>>> items = [[10, 11, 12], [20, 21], [30, 31, 32, 33]]
>>> sequence = abjad.sequence(items)
>>> for item in sequence.zip(cyclic=True):
...     item
...
Sequence([10, 20, 30])
Sequence([11, 21, 31])
Sequence([12, 20, 32])
Sequence([10, 21, 33])

Zips without truncation:

>>> items = [[1, 2, 3, 4], [11, 12, 13], [21, 22, 23]]
>>> sequence = abjad.sequence(items)
>>> for item in sequence.zip(truncate=False):
...     item
...
Sequence([1, 11, 21])
Sequence([2, 12, 22])
Sequence([3, 13, 23])
Sequence([4])

Zips strictly:

>>> items = [[1, 2, 3, 4], [11, 12, 13], [21, 22, 23]]
>>> for item in abjad.sequence(items).zip():
...     item
...
Sequence([1, 11, 21])
Sequence([2, 12, 22])
Sequence([3, 13, 23])

Returns nested sequence.

Special methods

Sequence.__add__(argument)

Adds argument to sequence.

Adds tuple to sequence:

>>> abjad.Sequence([1, 2, 3]) + (4, 5, 6)
Sequence([1, 2, 3, 4, 5, 6])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression + (4, 5, 6)
>>> expression([1, 2, 3])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'J + (4, 5, 6)'
>>> markup = expression.get_markup()
>>> show(markup) 

Adds list to sequence:

>>> abjad.Sequence([1, 2, 3]) + [4, 5, 6]
Sequence([1, 2, 3, 4, 5, 6])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression + [4, 5, 6]
>>> expression([1, 2, 3])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'J + [4, 5, 6]'
>>> markup = expression.get_markup()
>>> show(markup) 

Adds sequence to sequence:

>>> sequence_1 = abjad.Sequence([1, 2, 3])
>>> sequence_2 = abjad.Sequence([4, 5, 6])
>>> sequence_1 + sequence_2
Sequence([1, 2, 3, 4, 5, 6])
>>> expression_1 = abjad.Expression(name='J')
>>> expression_1 = expression_1.sequence()
>>> expression_2 = abjad.Expression(name='K')
>>> expression_2 = expression_2.sequence()
>>> expression = expression_1 + expression_2
>>> expression([1, 2, 3], [4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'J + K'
>>> markup = expression.get_markup()
>>> show(markup) 

Reverses result:

>>> sequence_1 = abjad.Sequence([1, 2, 3])
>>> sequence_2 = abjad.Sequence([4, 5, 6])
>>> sequence = sequence_1 + sequence_2
>>> sequence.reverse()
Sequence([6, 5, 4, 3, 2, 1])
>>> expression_1 = abjad.Expression(name='J')
>>> expression_1 = expression_1.sequence()
>>> expression_2 = abjad.Expression(name='K')
>>> expression_2 = expression_2.sequence()
>>> expression = expression_1 + expression_2
>>> expression = expression.reverse()
>>> expression([1, 2, 3], [4, 5, 6])
Sequence([6, 5, 4, 3, 2, 1])
>>> expression.get_string()
'R(J + K)'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

Sequence.__eq__(argument)

Is true when argument is a sequence with items equal to those of this sequence. Otherwise false.

Is true when argument is a sequence with items equal to those of this sequence:

>>> abjad.Sequence([1, 2, 3, 4, 5, 6]) == abjad.Sequence([1, 2, 3, 4, 5, 6])
True

Is false when argument is not a sequence with items equal to those of this sequence:

>>> abjad.Sequence([1, 2, 3, 4, 5, 6]) == ([1, 2, 3, 4, 5, 6])
False

Returns true or false.

Sequence.__format__(format_specification='')

Formats sequence.

Formats sequence:

>>> f(abjad.Sequence([1, 2, 3, 4, 5, 6]))
Sequence([1, 2, 3, 4, 5, 6])

Formats expression:

>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> f(expression)
abjad.Expression(
    callbacks=[
        abjad.Expression(
            evaluation_template='abjad.Sequence',
            is_initializer=True,
            string_template='{}',
            ),
        ],
    name='J',
    proxy_class=abjad.Sequence,
    )

Returns string.

Sequence.__getitem__(argument)

Gets item or slice identified by argument.

Gets first item in sequence:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence[0]
1
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression[0]
>>> expression([1, 2, 3, 4, 5, 6])
1
>>> expression.get_string()
'J[0]'
>>> markup = expression.get_markup()
>>> show(markup) 

Gets last item in sequence:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence[-1]
6
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression[-1]
>>> expression([1, 2, 3, 4, 5, 6])
6
>>> expression.get_string()
'J[-1]'
>>> markup = expression.get_markup()
>>> show(markup) 

Gets slice from sequence:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence = sequence[:3]
>>> sequence
Sequence([1, 2, 3])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression[:3]
>>> expression([1, 2, 3, 4, 5, 6])
Sequence([1, 2, 3])
>>> expression.get_string()
'J[:3]'
>>> markup = expression.get_markup()
>>> show(markup) 

Gets item in sequence and wraps result in new sequence:

>>> sequence = abjad.Sequence([1, 2, 3, 4, 5, 6])
>>> sequence = abjad.Sequence(sequence[0])
>>> sequence
Sequence([1])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression[0]
>>> expression = expression.sequence()
>>> expression([1, 2, 3, 4, 5, 6])
Sequence([1])
>>> expression.get_string()
'J[0]'
>>> markup = expression.get_markup()
>>> show(markup) 

Gets slice from sequence and flattens slice:

>>> sequence = abjad.Sequence([1, 2, [3, [4]], 5])
>>> sequence = sequence[:-1]
>>> sequence = sequence.flatten()
>>> sequence
Sequence([1, 2, 3, 4])
>>> expression = abjad.Expression(name='J')
>>> expression = expression.sequence()
>>> expression = expression[:-1]
>>> expression = expression.flatten()
>>> expression([1, 2, [3, [4]], 5])
Sequence([1, 2, 3, 4])
>>> expression.get_string()
'flatten(J[:-1])'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns item or new sequence.

Sequence.__hash__()

Hashes sequence.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

Sequence.__len__()

Gets length of sequence.

Gets length of sequence:

>>> len(abjad.Sequence([1, 2, 3, 4, 5, 6]))
6

Gets length of sequence:

>>> len(abjad.Sequence('text'))
4

Returns nonnegative integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

Sequence.__radd__(argument)

Adds sequence to argument.

Adds sequence to tuple:

>>> (1, 2, 3) + abjad.Sequence([4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression = abjad.Expression(name='K')
>>> expression = expression.sequence()
>>> expression = (1, 2, 3) + expression
>>> expression([4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'(1, 2, 3) + K'
>>> markup = expression.get_markup()
>>> show(markup) 

Adds sequence to list:

>>> [1, 2, 3] + abjad.Sequence([4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression = abjad.Expression(name='K')
>>> expression = expression.sequence()
>>> expression = [1, 2, 3] + expression
>>> expression([4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'[1, 2, 3] + K'
>>> markup = expression.get_markup()
>>> show(markup) 

Adds sequence to sequence:

>>> abjad.Sequence([1, 2, 3]) + abjad.Sequence([4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression_1 = abjad.Expression(name='J')
>>> expression_1 = expression_1.sequence()
>>> expression_2 = abjad.Expression(name='K')
>>> expression_2 = expression_2.sequence()
>>> expression = expression_1 + expression_2
>>> expression([1, 2, 3], [4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])
>>> expression.get_string()
'J + K'
>>> markup = expression.get_markup()
>>> show(markup) 

Returns new sequence.

Sequence.__repr__()

Gets interpreter representation of sequence.

Gets interpreter representation:

>>> abjad.Sequence([99])
Sequence([99])

Gets interpreter representation:

>>> abjad.Sequence([1, 2, 3, 4, 5, 6])
Sequence([1, 2, 3, 4, 5, 6])

Returns string.