Module: sage.combinat.misc
Miscellaneous
Module-level Functions
l) |
sage: from sage.combinat.misc import check_integer_list_constraints sage: cilc = check_integer_list_constraints sage: l = [[2,1,3],[1,2],[3,3],[4,1,1]] sage: cilc(l, min_part=2) [[3, 3]] sage: cilc(l, max_part=2) [[1, 2]] sage: cilc(l, length=2) [[1, 2], [3, 3]] sage: cilc(l, max_length=2) [[1, 2], [3, 3]] sage: cilc(l, min_length=3) [[2, 1, 3], [4, 1, 1]] sage: cilc(l, max_slope=0) [[3, 3], [4, 1, 1]] sage: cilc(l, min_slope=1) [[1, 2]] sage: cilc(l, outer=[2,2]) [[1, 2]] sage: cilc(l, inner=[2,2]) [[3, 3]]
sage: cilc([1,2,3], length=3, singleton=True) [1, 2, 3] sage: cilc([1,2,3], length=2, singleton=True) is None True
poly) |
Returns the umbral operation
applied to poly.
The umbral operation replaces each instance of
with
.
sage: P = PolynomialRing(QQ, 2, 'x') sage: x = P.gens() sage: from sage.combinat.misc import umbral_operation sage: umbral_operation(x[0]^3) == x[0]*(x[0]-1)*(x[0]-2) True sage: umbral_operation(x[0]*x[1]) x0*x1 sage: umbral_operation(x[0]+x[1]) x0 + x1 sage: umbral_operation(x[0]^2*x[1]^2) == x[0]*(x[0]-1)*x[1]*(x[1]-1) True
Class: DoublyLinkedList
Note that this list's indexing is 1-based.
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]); dll Doubly linked list of [1, 2, 3]: [1, 2, 3] sage: dll.hide(1); dll Doubly linked list of [1, 2, 3]: [2, 3] sage: dll.unhide(1); dll Doubly linked list of [1, 2, 3]: [1, 2, 3] sage: dll.hide(2); dll Doubly linked list of [1, 2, 3]: [1, 3] sage: dll.unhide(2); dll Doubly linked list of [1, 2, 3]: [1, 2, 3]
self, l) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll == loads(dumps(dll)) True
Functions: head,
hide,
next,
prev,
unhide
self) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll.head() 1 sage: dll.hide(1) sage: dll.head() 2
self, i) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll.hide(1) sage: list(dll) [2, 3]
self, j) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll.next(1) 2 sage: dll.hide(2) sage: dll.next(1) 3
self, j) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll.prev(3) 2 sage: dll.hide(2) sage: dll.prev(3) 1
self, i) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll.hide(1); dll.unhide(1) sage: list(dll) [1, 2, 3]
Special Functions: __cmp__,
__init__,
__iter__,
__repr__
self, x) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll2 = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: dll == dll2 True sage: dll.hide(1) sage: dll == dll2 False
self) |
TESTS:
sage: dll = sage.combinat.misc.DoublyLinkedList([1,2,3]) sage: list(dll) [1, 2, 3]
self) |
TESTS:
sage: repr(sage.combinat.misc.DoublyLinkedList([1,2,3])) 'Doubly linked list of [1, 2, 3]: [1, 2, 3]'
Class: IterableFunctionCall
sage: def f(): yield 'a'; yield 'b'
This does not work:
sage: for z in f: print z Traceback (most recent call last): ... TypeError: 'function' object is not iterable
Use IterableFunctionCall if you want something like the above to work:
sage: from sage.combinat.misc import IterableFunctionCall sage: g = IterableFunctionCall(f) sage: for z in g: print z a b
self, f) |
sage: from sage.combinat.misc import IterableFunctionCall sage: IterableFunctionCall(iter, [1,2,3]) Iterable function call <built-in function iter> with args=([1, 2, 3],) and kwargs={}
Special Functions: __init__,
__iter__,
__repr__
self) |
sage: from sage.combinat.misc import IterableFunctionCall sage: list(iter(IterableFunctionCall(iter, [1,2,3]))) [1, 2, 3]
self) |
sage: from sage.combinat.misc import IterableFunctionCall sage: repr(IterableFunctionCall(iter, [1,2,3])) 'Iterable function call <built-in function iter> with args=([1, 2, 3],) and kwargs={}'