Note
This module will be deleted in a future version of Sage. Most of the commands here have been already deleted; only the commands needed for unpickling word objects saved with older versions of Sage (pre 4.1) have been kept (for now).
Builds the content for a word.
INPUT:
OUTPUT:
TESTS:
sage: from sage.combinat.words.word_content import BuildWordContent
sage: from itertools import count, imap, repeat
sage: len(BuildWordContent(None))
doctest:...: DeprecationWarning: WordContentFromList is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
doctest:...: DeprecationWarning: WordContentFromList is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
0
sage: len(BuildWordContent(None, format='empty'))
0
sage: c = BuildWordContent(['a', 'b'], format='empty')
...
TypeError: trying to build an empty word with something other than None
sage: len(BuildWordContent(['0', '1', '1'], int))
doctest:...: DeprecationWarning: WordContentFromList is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
3
sage: len(BuildWordContent(['0', '1', '1'], int, format='list'))
3
sage: BuildWordContent(10, format='list')
...
TypeError: trying to build a word backed by a list with a sequence not providing the required operations
sage: c = BuildWordContent(lambda x: x%2)
doctest:...: DeprecationWarning: WordContentFromFunction is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
doctest:...: DeprecationWarning: WordContentFromFunction is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
sage: len(BuildWordContent(lambda x: x%3, part=slice(0,10)))
10
sage: c = BuildWordContent(repeat(1))
doctest:...: DeprecationWarning: WordContentFromIterator is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
doctest:...: DeprecationWarning: WordContentFromIterator is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
sage: len(BuildWordContent(count(), part=slice(10)))
10
sage: len(BuildWordContent(count(), part=slice(10, 0, -2)))
doctest:...: DeprecationWarning: WordContentFromList is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
5
Bases: sage.combinat.words.word_content.WordContentFromFunction
Class that acts as a function to concatenate contents.
Bases: object
Method to concatenate two contents together.
TESTS:
sage: from sage.combinat.words.word_content import BuildWordContent
sage: list(BuildWordContent([1]).concatenate(BuildWordContent([2, 3, 4])))
doctest:...: DeprecationWarning: ConcatenateContent is deprecated and will be deleted in a future version of Sage; see sage.combinat.words.word_datatypes for alternatives
[1, 2, 3, 4]
Returns True if obj is the content of a word.
EXAMPLES:
sage: from sage.combinat.words.word_content import BuildWordContent, is_WordContent
sage: is_WordContent(33)
False
sage: is_WordContent(BuildWordContent([0, 1, 0], lambda x : x))
True