List Functions
[Functions]


Functions

list CombIdxList (counter Count, counter Choose)
 Returns a list of all index combinations according to the expression 'n choose k'.
void InsList (list lL, counter iWhere, list lM)
 This function inserts a given list in a list.
void InsList (list lL, counter iWhere, counter iCount)
 This function inserts a given number of entries in a list.
list List (string sText, string sDel)
 Generates a list of substrings from a strings by cutting the string at delimiter strings.
list List (matrix mA)
 Generates a nested list of the components of a matrix.
list List (multivector vA)
 Generates a list of the components of a multivector.
list List (counter iSize)
 Generates a list of size iSize.
list PermIdxList (counter Count, counter Choose)
 Returns a list of index permutations that are necessary to select all possible sublists of a certain length from a given set.
void RemList (list L, list F)
 Removes selected elements from a given list.
list RemList (list L, counter First, counter Count)
 Removes a sublist from a list.
list SubList (list L, list F)
 Returns a sublist extracted from a given list.
list SubList (list L, counter First, counter Count)
 Returns a sublist extracted from a given list.
list TransList (list lL, counter iLevel)
 Transposition of list elements.

Detailed Description

Functions that deal with lists.

Function Documentation

list CombIdxList counter  Count,
counter  Choose
 

Returns a list of all index combinations according to the expression 'n choose k'.

Parameters:
Count A counter representing the number of elements in a set from that Choose elements are to be choosen.
Choose A counter representing the number of elements to be choosen.
Returns:
A list of length $\mathtt{Count}\choose \mathtt{Choose}$ containing lists of indices that have the length Choose.
Since:
v2.0
The elements of the returned list are sorted in ascending order. The expression ?CombIdxList(4,2); results in

    
    Constant = [[[1], [2]], [[1], [3]], [[1], [4]], [[2], [3]], [[2], [4]], [[3], [4]]]

void InsList list  lL,
counter  iWhere,
list  lM
 

This function inserts a given list in a list.

Parameters:
lL The list in which values are inserted.
iWhere The index of the element in the list lL before which the insertion occurs.
lM The list of values that are to be inserted.
Returns:
Nothing.
Here is an example.

    ?lL = [1,2,3];
    InsList(lL, 2, [5,6]);
    ?lL;

Output:

lL (3)=
[ 1 , 2 , 3 ]


lL (5)=
[ 1 , 5 , 6 , 2 , 3 ]


void InsList list  lL,
counter  iWhere,
counter  iCount
 

This function inserts a given number of entries in a list.

Parameters:
lL The list in which values are inserted.
iWhere The index of the element in the list lL before which the insertion occurs.
iCount The number of elements that are to be inserted.
Returns:
Nothing.
Here is an example.

    ?lL = [1,2,3];
    InsList(lL, 2, 2);
    ?lL;

Output:

lL (3)=
[ 1 , 2 , 3 ]


lL (5)=
[ 1 , 0 , 0 , 2 , 3 ]


list List string  sText,
string  sDel
 

Generates a list of substrings from a strings by cutting the string at delimiter strings.

Parameters:
sText The text string.
sDel The delimiter string.
Returns:
A list of substrings.
The delimiter string may be a single symbol like ',', or a string itself. For example, consider the following line of code.

    ?lL = List("Hello World this is a test!", " ");

Output:

lL (6)=
[ Hello , World , this , is , a , test! ]


This functionality can be particularly useful when analysing a list of numbers read in from a text file. For example,

    ?lL = List( "1.2, 3.4, -5.321", "," );
    ?vA = VecE3( Scalar( lL ) );

Output:

lL (3)=
[ 1.2 , 3.4 , -5.321 ]


vA = 1.2 e1 + 3.4 e2 + -5.32 e3

list List matrix  mA  ) 
 

Generates a nested list of the components of a matrix.

Parameters:
mA The matrix.
Returns:
A nested list with the components of mA.
    ?List(Matrix(2,3));

Output:

Constant (2)=
[ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ]


list List multivector  vA  ) 
 

Generates a list of the components of a multivector.

Parameters:
vA The multivector.
Returns:
A list with the components of vA.
The length of the list returned is equal to the dimension of the algebra of the multivector.

    DefVarsE3();
    ?lVec = List(1 + 2*e1 + 3*e3*e2 + 4*e1*e2 + 5*e1*e2*e3);

Output:

lVec (8)=
[ 1 , 2 , 0 , 0 , -3 , 0 , 4 , 5 ]


list List counter  iSize  ) 
 

Generates a list of size iSize.

Parameters:
iSize The number of entries in the list.
Returns:
A list with iSize entries, which are all set to 0.

list PermIdxList counter  Count,
counter  Choose
 

Returns a list of index permutations that are necessary to select all possible sublists of a certain length from a given set.

Parameters:
Count A counter representing the number of elements in a set from that Choose elements are to be chosen.
Choose A counter representing the number of elements to be chosen.
Returns:
A list of length ${\mathtt{Count}\choose \mathtt{Choose}}\cdot\mathtt{Choose}\,!$ containing all possible lists of indices that have the length Choose.
Since:
v2.0
All permutations of elements in the return of function CombIdxList are enclosed in the return of function PermIdxList. Thus if $[[a], [b], [c]]$ is element of the result of CombIdxList, then $[[a], [c], [b]]$ , $[[b], [a], [c]]$ , $[[b], [c], [a]]$ , $[[c], [a], [b]]$ and $[[c], [b], [a]]$ will be elements of the result of PermIdxList. Therefore the expression ?PermIdxList(3,2); results in

    
    Constant = [[[1], [2]], [[2], [1]], [[1], [3]], [[3], [1]], [[2], [3]], [[3], [2]]]

void RemList list  L,
list  F
 

Removes selected elements from a given list.

Parameters:
L A list.
F A list that specifies the elements of L to be removed.
Returns:
Nothing.
Since:
v2.0
This function removes top level elements from the list L. Single indices may also be passed to the function.

    
    ? L = [ 8,7,6,5,4 ];
    RemList(L, 3  );
    ? L;
    RemList(L, [1, 3]  );
    ?L; 
The example results in
    L = [8, 7, 6, 5, 4]
    L = [8, 7, 5, 4]
    L = [7, 4]

list RemList list  L,
counter  First,
counter  Count
 

Removes a sublist from a list.

Parameters:
L A list.
First The position in list L from where to start to remove the sublist.
Count The number of element to remove from L starting from First.
Returns:
The specified remaining part of list L.
Since:
v2.0
Attention:
The function changes list L directly, i.e. no futher assignment to L is necessary.
This function removes a coherent part from a given list L. The first element that is to be removed is the element of L at position First. The last element is the element of L at position (First + Count - 1). If Count is -1, then all elements of L starting with element First are removed. Here is an example,
    
    ? L = [ 8,7,6,5,4,3 ];
    RemList(L, 4,-1 );      // remove, starting with 4th element, up to the end
    ? L;
    RemList(L, 1,2 );       // remove, starting with 1st element, two elements
    ? L;

This code produces the following output.

    L = [8, 7, 6, 5, 4]
    L = [8, 7, 6]
    L = [6]

list SubList list  L,
list  F
 

Returns a sublist extracted from a given list.

Parameters:
L A list.
F A list that determines the components to be extracted.
Returns:
The sublist of L, specified by the parameters.
Since:
v2.0
This function extracts a sublist from the given list L. The elements of list F determine how to branch within the list L. An element f = [ 1,2 ] in F stands e.g. for 'Take the 2nd element of the 1st element of L', that is L(1)(2). The result might be a scalar or still a sublist. Note that this function has an equivalent expressiveness as the bracket operator ( ) applied to lists. Here is a comprehensive example,

    
    ? L = [ [ [3,1],[9,1,0] ],[ -2,7,1,8 ] ];
    ? S = SubList(L, [ 1,2 ]);                  // =  SubList(L, [ [1], [2] ]);
    ? S = SubList(L, [ [1,2] ]);
    ? S = SubList(L, [ [1,2,3] ]);
    ? S = SubList(L, [ [1,1,1],[2,1] ]);        // =  L([ [1,1,1], [2,1] ]);

This code produces the following output.

    
    L = [[[3, 1], [9, 1, 0]], [-2, 7, 1, 8]]
    S = [[[3, 1], [9, 1, 0]], [-2, 7, 1, 8]]
    S = [[9, 1, 0]]
    S = [0]
    S = [3, -2]

list SubList list  L,
counter  First,
counter  Count
 

Returns a sublist extracted from a given list.

Parameters:
L A list.
First The position in list L from where to start to extract the sublist.
Count The number of element to extract from L starting from First.
Returns:
The sublist of L, specified by the parameters.
Since:
v2.0
This function extracts a sublist from the given list L. The first element in the sublist is the element of L at position First. The last element in the returned sublist is the element of L at position (First + Count - 1). If Count is -1, then all elements of L starting with element First are taken. Here is an example,

    
    ?L = [1, 2, 3, 4, 5];
    
    ?SubList(L, 2, 3);
    ?SubList(L, 2, -1);

This code produces the following output.

    
    L = [1, 2, 3, 4, 5]
    Constant = [2, 3, 4]
    Constant = [2, 3, 4, 5]

list TransList list  lL,
counter  iLevel
 

Transposition of list elements.

Parameters:
lL The list that is to be transposed.
iLevel (optional) The nesting level at which transposition should occur. The default is 0.
Returns:
The transposed list.
This function can also be used to transform an index lists into a list of numbers. For example,

    ?lL = [[1], [2], [3]];
    ?lM = TransList(lL);

Output:

lL (3)=
[ [ 1 ] , [ 2 ] , [ 3 ] ]


lM (1)=
[ [ 1 , 2 , 3 ] ]


If the list lL is interpreted as a matrix, then it represents a single column vector. The transpose is therefore a single row vector. Note that not all sublists need to be of the same length. For example,

    ?lL = [[1,2], [3,4,5], [6,7]];
    ?lM = TransList(lL);

Output:

lL (3)=
[ [ 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 ] ]


lM (3)=
[ [ 1 , 3 , 6 ] , [ 2 , 4 , 7 ] , [ 5 ] ]


The optional parameter iLevel sets the level at which the transpose is to be executed. This only has an effect for multiply nested lists. Consider the following example.

    ?lL = [ 
            [[1,2], [3,4], [5,6]],
            [[7,8], [9,10], [11,12]]
           ];
    
    ?lM1 = TransList(lL);
    ?lM2 = TransList(lL, 1);    

Output:

lL (2)=
[ [ [ 1 , 2 ] , [ 3 , 4 ] , [ 5 , 6 ] ] , [ [ 7 , 8 ] , [ 9 , 10 ] , [ 11 , 12 ] ] ]


lM1 (3)=
[ [ [ 1 , 2 ] , [ 7 , 8 ] ] , [ [ 3 , 4 ] , [ 9 , 10 ] ] , [ [ 5 , 6 ] , [ 11 , 12 ] ] ]


lM2 (2)=
[ [ [ 1 , 3 , 5 ] , [ 2 , 4 , 6 ] ] , [ [ 7 , 9 , 11 ] , [ 8 , 10 , 12 ] ] ]