Ask Your Question
1

Letter separator in words when alphabet has multicharacter letters

asked 2021-01-18 11:56:22 +0200

qfaes gravatar image

updated 2021-01-18 12:21:50 +0200

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-01-18 12:20:26 +0200

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]
edit flag offensive delete link more

Comments

Thank you !

qfaes gravatar imageqfaes ( 2021-01-18 12:56:45 +0200 )edit

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: 2021-01-18 11:56:22 +0200

Seen: 297 times

Last updated: Jan 18 '21