[GAP Forum] Identical objects that are indices (not lists) ?

wh at icparc.ic.ac.uk wh at icparc.ic.ac.uk
Wed Apr 6 08:07:49 BST 2005


Hi,

Since the identical lists feature is the kind of thing you're looking for,
could you not just use that?  I.e. use a couple of length 1 lists.  E.g.:

    abc := function(A,flag)
	local i,j,ii,jj;

	ii := [];
	if flag then
	    jj := ii;
	else
	    jj := [1];
	fi

	for i in [1..d] do
	    ii[1] := i;
	    for j in [jj[1]..d] do
		# various_functions(i, j, A[i][j])
		# same for both cases
	    od;
	od;
    end;

If you're only referring to i once or twice in the body of the loop it might
be more efficient to drop the "ii[1] := i" and replace all occurrences of i
by ii[1].

Cheers,
Warwick




More information about the Forum mailing list