On Thursday, June 28, 2012 10:39:01 PM UTC-4, kcrisman wrote:
>
> Hi Walter!
>
> On Thursday, June 28, 2012 8:11:55 PM UTC-4, Walter Carlip wrote:
>>
>> I am having trouble using Gap within Sage. Often things fail to print or
>> to work from Sage even though they do work directly in Gap. How do I
>> report bugs and get help? Here is a sample program my tutors devised that
>> does not print under Sage, but works fine directly in Gap:
>>
>> for n in [1..10] do
>> for m in [1..10] do
>> Print(m*n);
>> Print(" - ");
>> od;
>> Print("\n");
>> od;
>>
>> (Removing the second Print command makes it work. We have found many
>> other things like this that seem to fail without explanation.
>>
>
> Are you using this in the notebook? I can confirm this behavior in a
> %gap cell.
>
> There was, once upon a time, a problem with comments - see
> http://trac.sagemath.org/sage_trac/ticket/3752 . I feel like I've seen
> this before as well in the lists, but can't quite find it yet. #5043 and
> #3152 are conceivably, but unlikely to be, related. I'll keep looking.
>
>
We can see exactly what is going on with this in the source code at
http://hg.sagemath.org/sage-main/file/9ab4ab6e12d0/sage/interfaces/gap.py#l365
Notice that this has nothing to do with the notebook - if you make a raw
Python string
str = r"""
for n in [1..10] do
for m in [1..10] do
Print(m*n);
Print(" - ");
od;
Print("\n");
od;
"""
and do gap.eval(str) in Sage, the same problem happens.
Maybe one of the tutors can track down. Notice that
str1 = r"""
for n in [1..10] do
for m in [1..10] do
Print(m*n);
Print(" - ");
od;
od;
"""
gap.eval(str1)
erroneously adds newlines.
'1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 2 - 4 - 6 - 8 - 10 - 12 - 14 -
16 - \n18 - 20 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - 27 - 30 - 4 - 8 -
12 - 16 - \n20 - 24 - 28 - 32 - 36 - 40 - 5 - 10 - 15 - 20 - 25 - 30 -
35 - 40 - 45 - \n50 - 6 - 12 - 18 - 24 - 30 - 36 - 42 - 48 - 54 - 60 - 7
- 14 - 21 - 28 - 35 - \n42 - 49 - 56 - 63 - 70 - 8 - 16 - 24 - 32 - 40 -
48 - 56 - 64 - 72 - 80 - 9 - \n18 - 27 - 36 - 45 - 54 - 63 - 72 - 81 -
90 - 10 - 20 - 30 - 40 - 50 - 60 - \n70 - 80 - 90 - 100 -'
Oh, that's the problem.
gap.eval(str,newlines=False)
gives the correct answer. Now the question is, why?
This is now http://trac.sagemath.org/sage_trac/ticket/13178. Gap experts
are welcome here; maybe a newline is surreptitiously entered at the end of
a "od"?
- kcrisman
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org