Up

tupleSet

Set the value of an element of a tuple from its position.
If the position is out of range, the function will return nil.

This function should be reserved to the advanced developers only, a bad use can do something unwanted. A good use should be safe.

Usually, two cases can occur :

Prototype :

fun [u0 I u1] u0

Return : u0 the same tuple or nil if error

See also :

tupleGet

tupleSize

Example :

fun setTuple (tuple, c)=
	set tuple = tupleSet tuple 0 c;		// set the first element to 'c'
	if c < tupleGet tuple 1 nil then	// set the second element if the condition is true
		set tuple = tupleSet tuple 1 c + tupleGet tuple 1 nil;	// old value + 'c'
	else
		nil;
	0;;

fun initTuple (tuple, a, b)=
	set tuple = [a b b];
	// others things to do
	0;;

Note

The first element has always the index 0.