> < ^ Date: Fri, 21 Jan 1994 09:02:00 +0100
> < ^ From: Frank Celler <frank.celler@math.rwth-aachen.de >
^ Subject: [Michael Smith: Calling functions, printing records and matrix calculations]
From: Michael Smith@wintermute.anu.edu.au
Subject: Calling functions, printing records and matrix calculations
To: gap-forum@math.rwth-aachen.de
 A couple of suggestions, and a question.

LISP 'apply function:

Since LISP seems to have been an influence in the design of the GAP
language, I wondering whether there might be a (hidden?) function
equivalent to the LISP 'apply function. This function takes as arguments
a function F and a list L and its evaluation is equivalent to a call to F
with arguments given by the elements of L.

i.e. ApplyFunction(F,[a,b,c]) is equivalent to F(a,b,c)

It is useful in the following situation. Assume that I wish to break
whenever the Print function is called. Now I would like to set
PrintOriginal to Print and then redefine Print to be an Error() statement
follwed by a call to PrintOriginal. The problem is, since Print takes a
variable number of arguments, I cannot write a call to PrintOriginal that
duplicates the original call to Print. It is trivial to do this with
LISP's 'apply function.

Nonrecursive PrintRec:

Any chance of including a non-recursive PrintRec in future? When trying
to find out what the fields of a record are there can be an *enormous*
amount of output to wade through (try a GroupHomormorphismByImages

Matrix calculations:

I need to calculate a number of products of some matrices and add these
products together. What is the best way of doing this? The simplest
method, Sum([1..n], i -> A[i]*B[i]), uses much more space than necessary.
It should be possible to do all this using only two extra matrices, one
to accumulate the sum, the other to store each product. Can this be done?


  smith@maths.anu.edu.au     /-| |\ | |  |    Mathematics (CMA)

> < [top]