-
-
Notifications
You must be signed in to change notification settings - Fork 660
Closed
Milestone
Description
Before this ticket, count
depends on the representation (list vs str) in a surprising way, see this question on ask:
sage: s = 'aaabaaababaaaaabbbbb'
sage: u = Word(list(s))
sage: v = Word(s)
sage: u.count('ab')
0
sage: v.count('ab')
4
because
sage: type(v)
<class 'sage.combinat.words.word.FiniteWord_str'>
sage: type(u)
<class 'sage.combinat.words.word.FiniteWord_list'>
The proposed solution is to fix count
so that it behaves like list.count and tuple.count:
sage: list(u).count('ab')
0
sage: list(v).count('ab')
0
In the proposed branch, the method count
is now an alias to the method number_of_letter_occurrences
.
Doing so, we also deprecate few methods in favor of:
_pos_in -> first_occurrence
first_pos_in -> first_occurrence
factor_occurrences_in -> factor_occurrences_iterator
nb_factor_occurrences_in -> number_of_factor_occurrences
nb_subword_occurrences_in -> number_of_subword_occurrences
See also:
- Words: mention
nb_factor_occurrences
incount
documentation #30143: mentionnb_factor_occurrences
incount
documentation
Component: combinatorics
Keywords: words, count
Author: Sébastien Labbé
Branch/Commit: 4c9870d
Reviewer: Jonathan Kliem
Issue created by migration from https://trac.sagemath.org/ticket/30187