[NAME]
ALL.dao.type.list.method

[TITLE]
List Methods

[DESCRIPTION]


     
   1  list<@T=any>( count: int )[index: int => @T] => list<@T>
   2  list<@T=any>( count: int, init: @T )[index: int, prev: @T => @T] => list<@T>
   3  
   4  clear( self: list<@T> )
   5  size( invar self: list<@T> )=>int
   6  resize( self: list<@T<int|float|double|complex|string|enum>>, size: int )
   7  resize( self: list<@T>, value: @T, size: int )
   8  
   9  max( invar self: list<@T<int|float|double|complex|string|enum>> ) => tuple<@T,int>
  10  min( invar self: list<@T<int|float|double|complex|string|enum>> ) => tuple<@T,int>
  11  sum( invar self: list<@T<int|float|double|complex|string|enum>> ) => @T
  12  
  13  insert( self: list<@T>, item: @T, pos = 0 ) => list<@T>
  14  erase( self: list<@T>, start = 0, count = 1 ) => list<@T>
  15  join( self: list<@T>, other: list<@T>, ... : list<@T> ) => list<@T>
  16  append( self: list<@T>, item: @T, ... : @T ) => list<@T>
  17  push( self: list<@T>, item: @T, to: enum<front, back> = $back ) => list<@T>
  18  pop( self: list<@T>, from: enum<front,back> = $back ) => @T
  19  front( invar self: list<@T> ) => @T
  20  back( invar self: list<@T> ) => @T
  21  
  22  collect( invar self: list<@T>, direction: enum<forward,backward> = $forward )
  23      [item: @T, index: int => none|@V] => list<@V>
  24  collect( invar self: list<@T>, invar other: list<@S>, 
  25      direction: enum<forward,backward> = $forward )
  26      [item: @T, item2: @S, index: int => none|@V] => list<@V>
  27  associate( invar self: list<@T>, hashing = 0 )
  28      [item: invar<@T>, index: int => none|tuple<@K,@V>] => map<@K,@V>
  29  associate( invar self: list<@T>, invar other: list<@S>, hashing = 0 )
  30      [item: invar<@T>, item2: invar<@S>, index: int => none|tuple<@K,@V>]
  31      => map<@K,@V>
  32  reduce( invar self: list<@T>, direction: enum<forward,backward> = $forward )
  33      [item: invar<@T>, value: @T, index: int => @T] => @T|none
  34  reduce( invar self: list<@T>, init: @V,
  35      direction: enum<forward,backward> = $forward )
  36      [item: invar<@T>, value: @V, index: int => @V] => @V
  37  find( invar self: list<@T>, direction: enum<forward,backward> = $forward )
  38      [item: invar<@T>, index: int => int] => tuple<index:int,value:@T> | none
  39  iterate( invar self: list<@T>, direction: enum<forward,backward> = $forward )
  40      [item: invar<@T>, index: int]
  41  iterate( self: list<@T>, direction: enum<forward,backward> = $forward )
  42      [item: @T, index: int]
  43  
  44  sort( self: list<@T>, order: enum<ascend,descend> = $ascend, part = 0 ) => list<@T>
  45  sort( self: list<@T>, part = 0 )[X: @T, Y: @T => int] => list<@T>
  46  apply( self: list<@T>, direction: enum<forward,backward> = $forward )
  47      [item: @T, index: int => @T] => list<@T>
     


 0.1   Methods  


 0.1.1   list<@T=any>(count:int)[index:int=>@T]=>list<@T>  
     
   1  list<@T=any>( count: int )[index: int => @T] => list<@T>
     


 0.1.2   list<@T=any>(count:int,init:@T)[index:int,prev:@T=>@T]=>list<@T>  
     
   1  list<@T=any>( count: int, init: @T )[index: int, prev: @T => @T] => list<@T>
     


 0.1.3   clear(self:list<@T>)  
     
   1  clear( self: list<@T> )
     
Clear the list.

 0.1.4   size(invar self:list<@T>)=>int  
     
   1  size( invar self: list<@T> )=>int
     
Return the size of the list.

 0.1.5   resize(self:list<@T<int|float|double|complex|string|enum>>,size:int)  
     
   1  resize( self: list<@T<int|float|double|complex|string|enum>>, size: int )
     
Resize the list of primitive data to size "size".

 0.1.6   resize(self:list<@T>,value:@T,size:int)  
     
   1  resize( self: list<@T>, value: @T, size: int )
     
Resize the list to size "size", and fill the new items with value "value".

 0.1.7   max(invar self:list<@T<int|float|double|complex|string|enum>>)=>tuple<@T,int>  
     
   1  max( invar self: list<@T<int|float|double|complex|string|enum>> ) => tuple<@T,int>
     
Return the maximum value of the list and its index. The list has to contain primitive dat
a. In case of complex values, complex numbers are compared by the real part first, and th
en by the imaginary part.

 0.1.8   min(invar self:list<@T<int|float|double|complex|string|enum>>)=>tuple<@T,int>  
     
   1  min( invar self: list<@T<int|float|double|complex|string|enum>> ) => tuple<@T,int>
     
Return the minimum value of the list and its index.

 0.1.9   sum(invar self:list<@T<int|float|double|complex|string|enum>>)=>@T  
     
   1  sum( invar self: list<@T<int|float|double|complex|string|enum>> ) => @T
     
Return the sum of the list.

 0.1.10   insert(self:list<@T>,item:@T,pos=0)=>list<@T>  
     
   1  insert( self: list<@T>, item: @T, pos = 0 ) => list<@T>
     
Insert item "item" as position "pos". Return the self list;

 0.1.11   erase(self:list<@T>,start=0,count=1)=>list<@T>  
     
   1  erase( self: list<@T>, start = 0, count = 1 ) => list<@T>
     
Erase from the list "count" items starting from "start". Return the self list;

 0.1.12   join(self:list<@T>,other:list<@T>,...:list<@T>)=>list<@T>  
     
   1  join( self: list<@T>, other: list<@T>, ... : list<@T> ) => list<@T>
     
Join none or more lists at the end of the list. Return the self list;

 0.1.13   append(self:list<@T>,item:@T,...:@T)=>list<@T>  
     
   1  append( self: list<@T>, item: @T, ... : @T ) => list<@T>
     
Append item(s) at the end of the list. Return the self list;

 0.1.14   push(self:list<@T>,item:@T,to:enum<front,back>=$back)=>list<@T>  
     
   1  push( self: list<@T>, item: @T, to: enum<front, back> = $back ) => list<@T>
     
Push an item to the list, either at the front or at the back. Return the self list;

 0.1.15   pop(self:list<@T>,from:enum<front,back>=$back)=>@T  
     
   1  pop( self: list<@T>, from: enum<front,back> = $back ) => @T
     
Pop off an item from the list, either from the front or from the end. Return the popped i
tem.

 0.1.16   front(invar self:list<@T>)=>@T  
     
   1  front( invar self: list<@T> ) => @T
     
Get the front item of the list.

 0.1.17   back(invar self:list<@T>)=>@T  
     
   1  back( invar self: list<@T> ) => @T
     
Get the back item of the list.

 0.1.18   collect(invar self:list<@T>,direction:enum...)[...=>none|@V]=>list<@V>  
     
   1  collect( invar self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: @T, index: int => none|@V] => list<@V>
     
Iterate over the list and evaluate the code section on each item. The non-none values ret
urned by the code section are collected to create a new list which is then returned.
The iteration direction can be controlled by the "direction" parameter.
Note: invar<@T> will not match to none|@V;

 0.1.19   collect(invar self:list<@T>,invar other:list<@S>,...)[...=>none|@V]=>list<@V>  
     
   1  collect( invar self: list<@T>, invar other: list<@S>, 
   2      direction: enum<forward,backward> = $forward )
   3      [item: @T, item2: @S, index: int => none|@V] => list<@V>
     
Iterate over both lists simutaneously and evaluate the code section on each pair of their
corresponding items. The non-none values returned by the code section are collected to cr
eate a new list which is then returned.
The iteration direction can be controlled by the "direction" parameter.

 0.1.20   associate(invar self:list<@T>,hashing=0)[...=>none|tuple<@K,@V>]=>map<@K,@V>  
     
   1  associate( invar self: list<@T>, hashing = 0 )
   2      [item: invar<@T>, index: int => none|tuple<@K,@V>] => map<@K,@V>
     
Iterate over this list and evaluate the code section on the item value(s) and index. The 
code section may return none value, or a pair of key and value as a tuple. These keys and
values from the code section will produce a map/hash (associative array) which will be re
turned by the method.
The last optional parameter "hashing" may take the following values:
-- Zero: indicating the resulting map will be ordered by keys;
-- One : indicating the resulting map will be a hash map with the  default hashing seed;
-- Two : indicating the resulting map will be a hash map with a  random hashing seed;
-- Else: indicating the resulting map will be a hash map with this  "hashing" value as th
e hashing seed;

 0.1.21   associate(invar self:list<@T>,invar other:list<@S>,hashing=0)[...]=>map<@K,@V> 
 
     
   1  associate( invar self: list<@T>, invar other: list<@S>, hashing = 0 )
   2      [item: invar<@T>, item2: invar<@S>, index: int => none|tuple<@K,@V>]
   3      => map<@K,@V>
     
The same as above method except this method iterate over two lists.

 0.1.22   reduce(invar self:list<@T>,direction:enum...)[...=>@T]=>@T|none  
     
   1  reduce( invar self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: invar<@T>, value: @T, index: int => @T] => @T|none
     
Reduce (fold) the items of the list.
The process is the following:
1. The first item is taken as the initial and current value;
2. Starting from the second item, each item and the current value are  passed to the code
section to evaluate for a new current value;
3. Each new current value will be passed along with the next item  to do the same code se
ction evaluation to update the value.
4. When all items are processed, the current value will be returned.
The direction of iteration can be controlled by the "direction" paramter. If the list is 
empty, "none" will be returned.

 0.1.23   reduce(invar self:list<@T>,init:@V,direction:enum...)[...=>@V]=>@V  
     
   1  reduce( invar self: list<@T>, init: @V, direction: enum<forward,backward>
   2      = $forward ) [item: invar<@T>, value: @V, index: int => @V] => @V
     
Reduce (fold) the items of the list.
The process is essentially the same as the above "reduce()" method, except that:
1. The initial value is passed in as parameter, so the iteration will  start from the fir
st item;
2. The value produced by the code section does not have to be the same  as the items of t
he list;
3. When the list is empty, the "init" value will be returned.

 0.1.24   find(invar self:list<@T>,direction:...)[...]=>tuple<index:int,value:@T>|none  
     
   1  find( invar self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: invar<@T>, index: int => int] => tuple<index:int,value:@T> | none
     
Find the first item in the list that meets the condition as expressed by the code section
. A non-zero value of the code section indicates the condition is met. The direction of i
teration can be controlled by the "direction" paramter.

 0.1.25   iterate(invar self:list<@T>,direction:enum...)[item:invar<@T>,index:int]  
     
   1  iterate( invar self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: invar<@T>, index: int]
     
Iterate on the list. The direction of iteration can be controlled by the "direction" para
mter.

 0.1.26   iterate(self:list<@T>,direction:enum...)[item:@T,index:int]  
     
   1  iterate( self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: @T, index: int]
     
Iterate on the list. The direction of iteration can be controlled by the "direction" para
mter. The only difference from the above "iterate()" method is that this method cannot ta
ke constant list as the self parameter.

 0.1.27   sort(self:list<@T>,order:enum<ascend,descend>=$ascend,part=0)=>list<@T>  
     
   1  sort( self: list<@T>, order: enum<ascend,descend> = $ascend, part = 0 )
   2      => list<@T>
     
Sort the list by asceding or descending order. And stops when the largest "part" items (f
or descending sorting) or the smallest "part items (for asceding sorting) have been corre
ctly sorted, which also means the first "part" items in the (partially) sorted list are i
n the right positions. Zero "part" means sorting all items.

 0.1.28   sort(self:list<@T>,part=0)[X:@T,Y:@T=>int]=>list<@T>  
     
   1  sort( self: list<@T>, part = 0 )[X: @T, Y: @T => int] => list<@T>
     
Sort the list by ordering as defined by the code section. During the sorting, two items "
X" and "Y" will be passed to the code section for comparison, a non-zero value produced b
y the code section indicates "X" is less/smaller than "Y". The "part" parameter has the s
ame meaning as in the above "sort()" method.

 0.1.29   apply(self:list<@T>,direction:enum...)[item:@T,index:int=>@T]=>list<@T>  
     
   1  apply( self: list<@T>, direction: enum<forward,backward> = $forward )
   2      [item: @T, index: int => @T] => list<@T>
     
Apply new values to the items of the list. Each item and its index are passed to the code
section, and values produced by the code section are used to replace the items of the lis
t. The direction of iteration can be controlled by the "direction" paramter.