Skip to content

sage.combinat.subword.smallest_positions modifying its input (use #5200) #5534

@nthiery

Description

@nthiery

I came across this function in Sage-Combinat,

sage.combinat.subword.smallest_positions(word, subword, pos=0)

Running this function not only returns the positions in "word" where
"subword" occurs, but it modifies "subword" to be this sequence of
positions. Is there a reason for this? It seems to me that it should
leave "subword" unchanged, but maybe I'm not thinking of something.

sage: w = ["a", "b", "c", "d"]
sage: ww = ["b", "d"]
sage: sage.combinat.subword.smallest_positions(w, ww)
[1, 3]
sage: w
['a', 'b', 'c', 'd']
sage: ww
[1, 3]

Thanks,
Steve

CC: @sagetrac-sage-combinat

Component: combinatorics

Issue created by migration from https://trac.sagemath.org/ticket/5534

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions