Project

General

Profile

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

Functions

 std_tabClear (tab)
 Clear all values of a table to nil.
 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,.
 std_tabCmpStr (tab, index, string)
 Compare a string of an index with a given string.
 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,.
 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.
 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.
 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.
 std_tabCreate (size, f, x)
 Create an array and fill it.
 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,.
 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.
 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.
 std_tabGet (tab, index)
 Get the appropriate value to an index. The function verify if the index is not out of range.
 std_tabReset (tab, f, x)
 Reset all values of a table.
 std_tabSet (tab, index, value)
 Set the value to an index. The function verify if the index is not out of range.

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
<b>Prototype:</b> fun [tab u0 I u0] I

\param tab u0 : a table
\param I : an index
Parameters
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
<b>Prototype:</b> fun [tab u0 tab u0 I I] I

\param tab u0 : a table
\param tab u0 : another table
Parameters
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
<b>Prototype:</b> fun [tab u0 u0 I] I

\param tab u0 : a table
\param u0 : a value to find
Parameters
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