Word contents (DEPRECATED)

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).

sage.combinat.words.word_content.BuildWordContent(obj, mapping=<function id_f at 0xdb49f50>, format=None, part=slice(None, None, None))

Builds the content for a word.

INPUT:

  • obj - a function, an iterator or a list, potentially with a length defined
  • mapping - function, a map sending elements of the iterable to nonnegative integers.
  • format - string (default None), the explicit type of obj. Can be either ‘empty’, ‘list’, ‘function’ or ‘iterator’. If set to None (the default), the type will be guessed from the properties of obj.
  • part - slice (default slice(None)), the portion of the object to use

OUTPUT:

  • word content - an object respecting the word content protocol wrapping obj

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
class sage.combinat.words.word_content.ConcatenateContent(l)

Bases: sage.combinat.words.word_content.WordContentFromFunction

Class that acts as a function to concatenate contents.

class sage.combinat.words.word_content.WordContent

Bases: object

concatenate(other)

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]
class sage.combinat.words.word_content.WordContentFromFunction(func, trans=<function id_f at 0xdb49f50>)
Bases: sage.combinat.words.word_content.WordContent
class sage.combinat.words.word_content.WordContentFromIterator(it, trans=<function id_f at 0xdb49f50>)
Bases: sage.combinat.words.word_content.WordContent
class sage.combinat.words.word_content.WordContentFromList(l, trans=<function id_f at 0xdb49f50>)
Bases: sage.combinat.words.word_content.WordContent
sage.combinat.words.word_content.is_WordContent(obj)

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

Previous topic

Word utilities (DEPRECATED)

Next topic

Interval exchange transformations and linear involutions

This Page