[GAP Forum] some questions
Steve Linton
sal at cs.st-and.ac.uk
Sun Jun 17 21:29:37 BST 2007
Dear GAP Forum,
On Sun, 17 Jun 2007 14:31:50 -0400
"R. Keith Dennis" <dennis at rkd.math.cornell.edu> wrote:
> Dear Jack,
>
> thanks very much for this note, as well as your earlier note.
>
> Just what I needed!
>
Glad to hear it.
>
> I realize that GAP is extremely useful for interactive programming,
> and 'break'ing upon errors helps to detect & fix problems, but not
> being able to gracefully exit from a computation and continue on to
> the next case, makes things a bit difficult, but perhaps mainly for
> those not so familiar with what might go wrong.
>
> Thanks for the offer, but that's not necessary. I had hoped for a
> general solution that I presumed I had missed in the documentation.
>
> If there were a way to add such a feature to GAP it seems to me that
> it would be extremely valuable.
>
> I'm too accustomed to programming in perl where I protect myself
> (most of the time) by "if defined ... then".
>
We are working on this. Already, many functions return 'fail' rather than
giving errors (for instance trying to invert a singular matrix) to allow these
conditions to be detected, but we are working on a general mechanism for
catching errors.
> A related question: If one has defined a function of 2 or 3 or
> whatever variables of a certain type, is there a way to program in
> returning usage if no (or the wrong number, or type) entries are
> given? I write too many functions & it would be much more convenient
> if they would remind me as to what they do & what correct input should
> be, especially when I give them the wrong number of entries, or the
> wrong type.
The most general solution is write something like
foo := function(arg)
if Length(arg) <> 2 or
not IsWidget(arg[1]) or
not IsThingummy(arg[2]) then
Error("foo: arguments should be a widget and a thingummy");
fi;
I'll leave your remaining question, about normal subgroups for someone else to
answer.
Steve
--
Steve Linton School of Computer Science &
Centre for Interdisciplinary Research in Computational Algebra
University of St Andrews Tel +44 (1334) 463269
http://www.cs.st-and.ac.uk/~sal Fax +44 (1334) 463278
More information about the Forum
mailing list