Up |
forList
forList is a for-like from any list. This is a polymorphic function.
Prototype :
fun [fun [u0 I] u1 [u0 r1]] I
- fun [u0 I] u1 : function called to each item. The two arguments are : the value and the index
- [u0 r1] : any list
Return : I 0 if no error occurs during the loop, else nil
IMPORTANT : if function returns nil, the loop stops, similar at a 'break' instruction.
See also :
Example
typeof myList = [I r1];;
fun fDisplayList (item)=
_fooId item;; // 1 3 5 7 9
fun main ()=
_showconsole;
set myList = listRange 1 5 2; // listRange creates an integer list from an initial value, a size and an incremention value
forList @fDisplayList myList;
0;;
Note : if you need more arguments to 'fDisplayList', you can use mkfunX function(s) or use global(s) variable(s). An example can be found to set_nth_list.