ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 31 Dec 2011 04:26:07 -0600free algebra and indexed lettershttps://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/I try to work with a Combinatorial Free Module with basis a set of Words over an alphabet of indexed letters (y1,y2,...).
For example, I define
from sage.combinat.free_module import CombinatorialFreeModule as CFM
Mots=Words(['y1','y2','y3','y4','y5','y6','y7','y8'])
Module=CFM(QQ,Mots)
But I have some problems with the letters. For example :
mot=Word('y1')
sage: mot
word: y1
sage: mot in Mots
False
Is there a way to cure this problem ?Fri, 30 Dec 2011 05:41:57 -0600https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/Answer by John Palmieri for <p>I try to work with a Combinatorial Free Module with basis a set of Words over an alphabet of indexed letters (y1,y2,...).
For example, I define</p>
<p>from sage.combinat.free_module import CombinatorialFreeModule as CFM
Mots=Words(['y1','y2','y3','y4','y5','y6','y7','y8'])
Module=CFM(QQ,Mots)</p>
<p>But I have some problems with the letters. For example :</p>
<p>mot=Word('y1')
sage: mot
word: y1
sage: mot in Mots
False</p>
<p>Is there a way to cure this problem ?</p>
https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/?answer=13080#post-id-13080I think when you evaluate
mot=Word('y1')
it treats 'y' and '1' as separate characters, giving a word of length 2. Instead,
mot=Word(['y1'])
makes it have length one. To force it to live in Mots, do this:
sage: mot = Mots(Word(['y1']))
sage: Word(['y1']) in Mots
False
sage: Mots(Word(['y1'])) in Mots
True
Not ideal, but it seems to work.Fri, 30 Dec 2011 18:33:24 -0600https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/?answer=13080#post-id-13080Comment by Matthieu Deneufchâtel for <p>I think when you evaluate</p>
<pre><code>mot=Word('y1')
</code></pre>
<p>it treats 'y' and '1' as separate characters, giving a word of length 2. Instead,</p>
<pre><code>mot=Word(['y1'])
</code></pre>
<p>makes it have length one. To force it to live in Mots, do this:</p>
<pre><code>sage: mot = Mots(Word(['y1']))
sage: Word(['y1']) in Mots
False
sage: Mots(Word(['y1'])) in Mots
True
</code></pre>
<p>Not ideal, but it seems to work.</p>
https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/?comment=20609#post-id-20609Thanks, that helps !Sat, 31 Dec 2011 04:26:07 -0600https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/?comment=20609#post-id-20609