Up |
set_nth_list
Set an element of a list from its index.
Prototype :
fun [[u0 r1] I u0] [u0 r1]
- [u0 r1] : any list
- I : any index. if index is negative, index = 0. If index is out of range, set_nth_list will return nil
- u0 : new value
Return : [u0 r1] this list or nil if an error occurs.
See also :
Example :
fun fList (elt, index, list)=
_fooId index; // display the current index
if elt == 'z then
(
set list = set_nth_list list index 'e; // replace z to e
_fooS listtostr list; // display the new content (or use _fooSList directly)
nil // stop the loop (returning nil, see forList doc)
)
else
set list = set_nth_list list index elt;;
fun main ()=
_showconsole;
let "Hzllo World" -> string in
let strtolist string -> list in
_fooId forList mkfun3 @fList list list;
0;;