[Up] [Previous] [Next] [Index]

8.3 Lists and Matrices

  • IsListOfIntegers( list ) P

    IsListOfIntegers( list ) returns IsSubset(Integers, list ) if list is a dense list and false otherwise.

  • List2Tuples( list, int ) O

    If Size( list ) is divisible by int, List2Tuples( list,int) returns a list list2 of size int such that Concatenation( list2 )= list and every element of list2 has the same size.

    gap> List2Tuples([1..6],2);
    [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
    

  • MatTimesTransMat( mat ) O

    does the same as mat*TransposedMat( mat ) but uses slightly less space and time for large matrices.

  • PartitionByFunctionNF( list, f ) O

    PartitionByFunctionNF( list, f ) partitions the list list according to the values of the function f defined on list. If f returns fail for some element of list, PartitionByFunctionNF( list, f ) enters a break loop. Leaving the break loop with 'return;' is safe because PartitionByFunctionNF treats fail as all other results of f.

  • PartitionByFunction( list, f ) O

    PartitionByFunction( list, f ) partitions the list list according to the values of the function f defined on list. All elements, for which f returns fail are omitted, so PartitionByFunction does not necessarily return a partition. If InfoLevel(InfoRDS)indexInfoRDS@ttInfoRDS is at least 2, the number of elements for which f returns fail is shown (if fail is returned at all).

    
    gap> PartitionByFunctionNF([-1..5],x->x^2);
    [ [ 0 ], [ -1, 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]
    gap> test:=function(x) 
    > if x>0 then return Sqrt(x);
    >  else return fail;
    > fi;
    > end;
    function( x ) ... end
    gap> PartitionByFunction([-1..5],test);  
    [ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]
    gap> SetInfoLevel(InfoRDS,2);
    gap> PartitionByFunction([-1..5],test);  
    #I  -2-
    [ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ] ]
    gap> PartitionByFunctionNF([-1..5],test);
    Error, function returned <fail> called from
    ...
    brk> return;
    [ [ 1 ], [ 4 ], [ 5 ], [ 2 ], [ 3 ], [ -1, 0 ] ]
    

    [Up] [Previous] [Next] [Index]

    RDS manual
    November 2006