Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions
The table (array) API.

Functions

 std_tabClear (tab)
 Clear all values of a table to nil. More...
 
 std_tabCmp (tab, index, value)
 Compare a value of an index with a given value. All types are supported except S (string). For the last case,. More...
 
 std_tabCmpStr (tab, index, string)
 Compare a string of an index with a given string. More...
 
 std_tabCmpUntil (tab1, tab2, from, len)
 Compare all values from an index until a lenght between two tables. The first index is always 0 in a table. All types are supported except S (string). For the last case,. More...
 
 std_tabCmpUntilStr (tab1, tab2, from, len)
 Compare all strings from an index until a lenght between two tables. Function case-sensitive. The first index is always 0 in a table. More...
 
 std_tabCmpUntilStri (tab1, tab2, from, len)
 Compare all strings from an index until a lenght between two tables. Function case-insensitive. The first index is always 0 in a table. More...
 
 std_tabCopy (tab, size)
 Copy values of a table in a new table If the size of the table is smaller than the size of the new table, all other indexes are nil. More...
 
 std_tabCreate (size, f, x)
 Create an array and fill it. More...
 
 std_tabFind (tab, value, from)
 Searches a value in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table. All types are supported except S (string). For the last case,. More...
 
 std_tabFindStr (tab, str, from)
 Searches a string in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table. More...
 
 std_tabFindStri (tab, str, from)
 Searches a string in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table. More...
 
 std_tabGet (tab, index)
 Get the appropriate value to an index. The function verify if the index is not out of range. More...
 
 std_tabReset (tab, f, x)
 Reset all values of a table. More...
 
 std_tabSet (tab, index, value)
 Set the value to an index. The function verify if the index is not out of range. More...
 

Detailed Description

Package to load : lib/std/tab.pkg

Function Documentation

std_tabCreate ( size  ,
,
 
)

Create an array and fill it.

Prototype: fun [I fun [I u0] u1 u0] tab u1

Parameters
I: the size of the array
fun[I u0] u1 : function called to fill each element (the integer is the index)
u0: an user parameter to fill the array
Returns
tab u1 : the new array
std_tabGet ( tab  ,
index   
)

Get the appropriate value to an index. The function verify if the index is not out of range.

Prototype: fun [tab u0 I] u0

Parameters
tabu0 : a table
I: an index
Returns
u0 : the value or nil if the index is out of range (but the value can be nil itself)
std_tabSet ( tab  ,
index  ,
value   
)

Set the value to an index. The function verify if the index is not out of range.

Prototype: fun [tab u0 I u0] u0

Parameters
tabu0 : a table
I: an index
u0: the value
Returns
u0 : the same value or nil if the index is out of range (but the value can be nil itself)
std_tabCmp ( tab  ,
index  ,
value   
)

Compare a value of an index with a given value. All types are supported except S (string). For the last case,.

See also
std_tabCmpStr

Prototype: fun [tab u0 I u0] I

Parameters
tabu0 : a table
I: an index
u0: the value to compare
Returns
I : 1 if equal, 0 if not equal or nil if the index is out of range
std_tabCmpStr ( tab  ,
index  ,
string   
)

Compare a string of an index with a given string.

Prototype: fun [tab S I S] I

Parameters
tabS : a table
I: an index
S: the value to compare
Returns
I : 0 if equal, a negative or positive value if different or nil if the index is out of range
std_tabCmpUntil ( tab1  ,
tab2  ,
from  ,
len   
)

Compare all values from an index until a lenght between two tables. The first index is always 0 in a table. All types are supported except S (string). For the last case,.

See also
std_tabCmpUntilStr

Prototype: fun [tab u0 tab u0 I I] I

Parameters
tabu0 : a table
tabu0 : another table
I: an index to start
I: a length to the end
Returns
I : 1 if equal, 0 if not equal
std_tabCmpUntilStr ( tab1  ,
tab2  ,
from  ,
len   
)

Compare all strings from an index until a lenght between two tables. Function case-sensitive. The first index is always 0 in a table.

Prototype: fun [tab S tab S I I] I

Parameters
tabS : a table
tabS : another table
I: an index to start
I: a length to the end
Returns
I : 1 if equal, 0 if not equal (nil if internal error)
std_tabCmpUntilStri ( tab1  ,
tab2  ,
from  ,
len   
)

Compare all strings from an index until a lenght between two tables. Function case-insensitive. The first index is always 0 in a table.

Prototype: fun [tab S tab S I I] I

Parameters
tabS : a table
tabS : another table
I: an index to start
I: a length to the end
Returns
I : 1 if equal, 0 if not equal (nil if internal error)
std_tabFind ( tab  ,
value  ,
from   
)

Searches a value in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table. All types are supported except S (string). For the last case,.

See also
std_tabFindStr

Prototype: fun [tab u0 u0 I] I

Parameters
tabu0 : a table
u0: a value to find
I: an index to start
Returns
I : the index where the value has been found or nil if not found or error
std_tabFindStr ( tab  ,
str  ,
from   
)

Searches a string in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table.

Remarks
: this function is case-sensitive.

Prototype: fun [tab S S I] I

Parameters
tabS : a table
S: a value to find
I: an index to start
Returns
I : the index where the value has been found or nil if not found or error
std_tabFindStri ( tab  ,
str  ,
from   
)

Searches a string in a table from a position. To find all results, this function can be called from a loop/recursive function. The first index is always 0 in a table.

Remarks
: this function is case-insensitive.

Prototype: fun [tab S S I] I

Parameters
tabS : a table
S: a value to find
I: an index to start
Returns
I : the index where the value has been found or nil if not found or error
std_tabClear ( tab  )

Clear all values of a table to nil.

Remarks
: the size is unchanged, a table has always a fixed size ! Only values are nil.

Prototype: fun [tab u0] tab u0

Returns
tab u0 : the cleared table
std_tabReset ( tab  ,
,
 
)

Reset all values of a table.

Prototype: fun [tab u1 fun [I u0] u1 u0] tab u1

Parameters
tabu1 : a table already created
fun[I u0] u1 : function called to fill each element (the integer is the index)
u0: an user parameter to fill the array
Returns
tab u1 : the reset table
std_tabCopy ( tab  ,
size   
)

Copy values of a table in a new table If the size of the table is smaller than the size of the new table, all other indexes are nil.

Prototype: fun [tab u0 I] tab u0

Parameters
tabu0 : a table already created
I: the size of the new table
Returns
tab u0 : the new table or nil if error