[GAP Forum] strange error in while loop
Alexander Konovalov
alexk at mcs.st-andrews.ac.uk
Tue Nov 6 17:48:07 GMT 2012
Dear Prof. Schaps,
On 4 Nov 2012, at 14:31, Malka Schaps wrote:
> Dear All,
> I was implementing a Brauer character mapping for spin blocks, and
> used a loop
>
> Flag := 0
> while Flag = 0
> ...
> ...
> ...
> od;
> The loop worked fine and went around three times, and then at some point
> Flag := 1
>
> It got to the od; at the bottom, jumped up to the while and then I got
> an error message
>
> error no 1st choice method for '[ ]'with 2 arguments in Flag = 0 called
> from .....
>
>
> What causes such an error? I got it once before, when trying to read
> entries in an empty list, but Flag is not a list.
>
> Thanks,
> Malka Schaps
There may be several possible reasons for this message. First of all,
could you check what's the value of the variable Flag in the break loop:
brk> Flag;
- it may be that Flag is a global variable which was overwritten in some
other place. If this is the case, try to rename your 'Flag' to 'flag' or
something more unique.
Second, sometimes it's difficult for GAP to report the precise location
of an error, and the place is reported with the little offset. Errors
reporting was improved in GAP 4.5 - if you're using GAP 4.5 we would be
grateful if you could send us a simple example how to reproduce this
problem.
So, if this is the case, it may happen that the message
> no 1st choice method for '[ ]'with 2 arguments
comes from the line next to the one where the condition Flag=0 is
actually checked. You may try to instrument the code by adding
additional Print statements to catch the line which causes the
actual problem.
Finally, entering in GAP '??NoMethodFound' will display the manual
section "7.1 Recovery from NoMethodFound-Errors" which contains some
additional hints and auxiliary functions like 'ShowArguments' which
may be helpful in this case.
Hope this helps - please let me know if you would like further help.
Best regards,
Alexander
More information about the Forum
mailing list