ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 31 Dec 2011 11:26:07 +0100free 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 12:41:57 +0100https://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.Sat, 31 Dec 2011 01:33:24 +0100https://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 11:26:07 +0100https://ask.sagemath.org/question/8601/free-algebra-and-indexed-letters/?comment=20609#post-id-20609