Ask Your Question
1

Letter separator in words when alphabet has multicharacter letters

asked 4 years ago

qfaes gravatar image

updated 4 years ago

slelievre gravatar image

Why do i get:

sage: W = FiniteWords(['a','b'])
sage: [w for w in W.iterate_by_length(2)]

returns as I wish

[word: aa, word: ab, word: ba, word: bb]

but

sage: W = FiniteWords(['a1','a2'])
sage: [w for w in W.iterate_by_length(2)]

returns

[word: a1,a1, word: a1,a2, word: a2,a1, word: a2,a2]

I do not want the commas to appear here, how can I get

[word: a1a1, word: a1a2, word: a2a1, word: a2a2]

instead?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

slelievre gravatar image

The letter separator can be set globally using WordOptions.

In your case, you can set it to the empty string ''.

Here is an example with words of length two over the alphabet ['a1', 'a2'].

sage: W = FiniteWords(['a1', 'a2'])
sage: WordOptions(letter_separator='')
sage: [w for w in W.iterate_by_length(2)]
[word: a1a1, word: a1a2, word: a2a1, word: a2a2]
Preview: (hide)
link

Comments

Thank you !

qfaes gravatar imageqfaes ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 362 times

Last updated: Jan 18 '21